Jump to content

udp port connects


diveboy
 Share

Recommended Posts

Hi all,

we are working towards doing a server migration, part of which is cutting a netware server over to a new back end, new tree, new clients.

I have created several packages that will report back each stage of the workstation migration (enable Wake on Lan, list current printers, remove printers, remove clients, shutdown)

after we cut the servers over, I'm sending out a wake on lan packet to each workstation to bring them up.

What I need to do is to have an auto it script that when the machine wakes up, executes and then contacts a management workstation to find out if we are installing the new clients or we have had to back out the server upgrade and to reinstall all the old clients and reinstall the old printers.

to do this, i was thinking of having it connect via UDP to the management workstation running a udp server.

if it connects on port 55555 then it's the new environment

if it connects on port 44444 then it's the old environment

if it cant connect on either port, then sleep for 5 minutes and try re-connect.

how do I script this ? (this is just some quick hacking from the example files)

This is my UDP Server code

CODE
$udpport = 55555

UDPStartup()

$socket = UDPBind("127.0.0.1", $udpport)

If @error <> 0 Then Exit

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Func OnAutoItExit()

UDPCloseSocket($socket)

UDPShutdown()

EndFunc

This is my client code

CODE

$g_IP = "127.0.0.1"

$udpportnew = 55555

$udpportold = 44444

; Start The UDP Services

;==============================================

UDPStartUp()

$socket = UDPOpen("127.0.0.1", $udpportnew)

;this is where I need to determine if connected, if not, try the other port, if not, sleep and have a while loop.

Func OnAutoItExit()

UDPCloseSocket($socket)

UDPShutdown()

EndFunc

I'm not worried about the while loop, just how do i detect if it has successfully connected on the port or not ?

Thanks in advance for your help and time.

Link to comment
Share on other sites

Hi all,

we are working towards doing a server migration, part of which is cutting a netware server over to a new back end, new tree, new clients.

I have created several packages that will report back each stage of the workstation migration (enable Wake on Lan, list current printers, remove printers, remove clients, shutdown)

after we cut the servers over, I'm sending out a wake on lan packet to each workstation to bring them up.

What I need to do is to have an auto it script that when the machine wakes up, executes and then contacts a management workstation to find out if we are installing the new clients or we have had to back out the server upgrade and to reinstall all the old clients and reinstall the old printers.

to do this, i was thinking of having it connect via UDP to the management workstation running a udp server.

if it connects on port 55555 then it's the new environment

if it connects on port 44444 then it's the old environment

if it cant connect on either port, then sleep for 5 minutes and try re-connect.

how do I script this ? (this is just some quick hacking from the example files)

This is my UDP Server code

CODE
$udpport = 55555

UDPStartup()

$socket = UDPBind("127.0.0.1", $udpport)

If @error <> 0 Then Exit

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Func OnAutoItExit()

UDPCloseSocket($socket)

UDPShutdown()

EndFunc

This is my client code

CODE

$g_IP = "127.0.0.1"

$udpportnew = 55555

$udpportold = 44444

; Start The UDP Services

;==============================================

UDPStartUp()

$socket = UDPOpen("127.0.0.1", $udpportnew)

;this is where I need to determine if connected, if not, try the other port, if not, sleep and have a while loop.

Func OnAutoItExit()

UDPCloseSocket($socket)

UDPShutdown()

EndFunc

I'm not worried about the while loop, just how do i detect if it has successfully connected on the port or not ?

Thanks in advance for your help and time.

The client also binds to a port to wait for a reply from the server. The client sends some string to the server which includes the client's ip address and port to reply to. The server opens that ip address and port and sends a message back.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...