Borje Posted May 14, 2009 Share Posted May 14, 2009 (edited) Hello I try to understand how this works the problem I have is this I can not send over the string Hello World from the client to the server What have I done wrong here? The client have contact with the server but the messagebox message in the server pop up blank.Client_Test.au3Server_test.au3 Edited May 14, 2009 by Borje Link to comment Share on other sites More sharing options...
FreeFry Posted May 14, 2009 Share Posted May 14, 2009 First of all, in your server, to recieve data, you use the connected socket identifier(as returned by TCPAccept) not the main socket identifier(returned by TCPListen).Also in your client-script, because of that the script exits instantly after sending the bytes, causing the connected socket to be invalid(causing the server to miss the message as the socket gets disconnected).Modified your code a little:Server:TCPStartUp() $sListenAddress = @IPAddress1 $iListenPort = 8084 $iMainsocket = TCPListen($sListenAddress, $iListenPort) If $iMainsocket = -1 Then Exit(MsgBox(0, "Error", "Could not create the listening socket")) While 1 $ConnectedSocket = TCPAccept($iMainsocket) If $ConnectedSocket >= 0 Then $info=TCPRecv($ConnectedSocket,512) msgbox(0,"Display message !",$info) EndIf Sleep(250) WendClient:TCPStartUp() $g_IP = @IPAddress1 $Message = "Hello World" $socket = TCPConnect( $g_IP, 8084 ) TCPSend($socket,$message) Sleep(2500); Sleep some to keep the connection open, allowing the server to parse the message Link to comment Share on other sites More sharing options...
Borje Posted May 14, 2009 Author Share Posted May 14, 2009 Than you Free fry I tested this and I understand little more thanks again for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now