LurchMan Posted November 10, 2010 Share Posted November 10, 2010 Hey everyone - I'm working on a small Server / Client situation by just sending messages to the server (like it shows in the help file) which works fine the first time, but after that it looks like it sends the message, and doesn't present any errors, but the message doesn't show up on the server. Is there something I'm missing or is it not suppose to send multiple messages? Thanks for any help provided. Client: Func _LaunchJob($sJobName, $sCoder, $IP, $sRegion = "Test") Local $Port = 33891 Local $sParm = $sRegion & ' "' & $sJobName & '" ' & $sCoder $ConnectedSocket = TCPConnect($IP, $Port) If @error Then If @error = 10061 Then MsgBox(0, "", "Error: " & @error & @CRLF & "Server cannot be found.") Exit Else MsgBox(0, "", "Unknown Error: " & @error & @CRLF) Exit EndIf EndIf TCPSend($ConnectedSocket, $sParm) If @error Then MsgBox(16, "Error", "An error has occured when attempting to send message to server." & @CRLF & "Error: " & @error) EndIf EndFunc ;==>_LaunchJob Server: TCPStartup() $mainsocket = TCPListen(@IPAddress1, 33891) $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($mainsocket) Until $ConnectedSocket <> -1 While 1 $sParms = TCPRecv($ConnectedSocket, 2048) If @error Then ExitLoop If $sParms <> "" Then GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & _NowCalc() & ": " & $sParms & @CRLF) _LogIt(_NowCalc() & ": " & $sParms) _StartJob($sParms) EndIf WEnd _LogIt(_NowCalc() & ": " & "Client Disconnected.") MsgBox(0, "Close", "Client Disconnected.") TCPCloseSocket($ConnectedSocket) TCPShutdown() Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 10, 2010 Developers Share Posted November 10, 2010 Probably because you connect every time while your server goes from listening to process after the first connect by the client. Assume you do not get the client disconnected. message after the first time sending information? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
LurchMan Posted November 10, 2010 Author Share Posted November 10, 2010 No I do not. I do not know much about the TCP / IP stuff with scripting, would you mind elaborating a little more on that? Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 10, 2010 Developers Share Posted November 10, 2010 This is what meant: You connect each time you call _LaunchJob() ... this tries to initialise a new connection with the server. $ConnectedSocket = TCPConnect($IP, $Port) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
LurchMan Posted November 10, 2010 Author Share Posted November 10, 2010 Ok, so how would I get around that? Store the connected sockets in an array or is there a better way? There is a possibility of it sending commands to 6 different computers, and I cant have the same command going to each computer. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 10, 2010 Developers Share Posted November 10, 2010 (edited) Well you either connect one time and send all information after that or connect/send data/disconnect at the client side and after disconnection go back in listen mode at the server side. Jos Edited November 10, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
LurchMan Posted November 10, 2010 Author Share Posted November 10, 2010 Ok, I understand now, Thank you for your help. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. 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