Jump to content
Sign in to follow this  

another attempt, tcpsend / tcprecieve

Recommended Posts


AS per my previous post.

I'm writing a client that needs to query a server for a command, which can be one of three options, sleep, new build, old build, this is for a migration to a new netware environment.

I have hacked this from the examples and it's flaky at best when it does work.

I need to have a program running on a machine acting as a server, this has to send a command apon connection from the clients.

Server code

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 447, 193, 125)

$Radio1 = GUICtrlCreateRadio("Sleep", 40, 24, 137, 25)

$Radio2 = GUICtrlCreateRadio("New Build", 40, 56, 129, 17)

$Radio3 = GUICtrlCreateRadio("Old Build", 40, 72, 137, 41)


#EndRegion ### END Koda GUI section ###

;SERVER!! Start Me First !!!!!!!!!!!!!!!

$g_IP = @IPAddress1

$buildcommand = "Sleep"

; Start The TCP Services



msgbox(0,"Build Command", $buildcommand)

; Create a Listening "SOCKET"


$MainSocket = TCPListen($g_IP, 65432, 100 )

If $MainSocket = -1 Then Exit

; look for client connection


While 1

$ConnectedSocket = TCPAccept( $MainSocket)

If $ConnectedSocket >= 0 Then


TCPCloseSocket ($ConnectedSocket)


$nMsg = GUIGetMsg()

Switch $nMsg

Case $radio1

$buildcommand = "Sleep"

Case $radio2

$buildcommand = "New Build"

Case $radio3

$buildcommand = "Old Build"





Client code

$g_IP = @IPAddress1

; Start The TCP Services



; Create a Listening "SOCKET"


; look for client connection


While 1

;If $ConnectedSocket >= 0 Then


$MainSocket = TCPConnect ($g_IP, 65432)

;If $MainSocket = -1 Then Exit

$recv = TCPRecv( $MainSocket, 9)

msgbox(0,'Build Command',$recv,2 )

TCPCloseSocket ($MainSocket)

;msgbox(0,"","my server - Client Connected")





basically, it should work but doesn't. All I want it to do is connect to the server machine, find out what the command is and then go from there. I just can't seem to get it working properly. any assistance would be great

Thanks in advance


Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.