DarkNecromancer Posted November 15, 2005 Share Posted November 15, 2005 (edited) Hi, I'm trying to use the TCP connect to get my applications networkable. But I'm having problems getting it to work, and I've never had problems before and i can't figure out why I am now. So I come to you with this question, what am I doing wrong? I whipped up this code to see whats happening and as far as I can tell its accepting the connection from the second application correctly but it don't register when the user has left the socket. SERVER CODE:TCPStartup() $MainSocket = TCPListen( "127.0.0.1", 7000 ) Dim $socket=-1 WHile 1 If $socket >= 0 Then SplashTextOn( "Connected", "Main Socket State: " & $MainSocket & @CRLF & "Socket state: " & $socket ) Else $socket = TCPAccept($MainSocket) EndIf SplashTextOn( "Result", "Main Socket State: " & $MainSocket & @CRLF & "Socket state: " & $socket ) Sleep(1000) WEnd TCPShutdown() Client:TCPStartup() Dim $Socket = -1 While 1 If $socket = -1 Then $socket = TCPConnect( "127.0.0.1", 7000 ) Else msgbox(0,"","Connected") Exit EndIf WEnd TCPShutdown() Edited November 16, 2005 by DarkNecromancer Link to comment Share on other sites More sharing options...
DarkNecromancer Posted November 16, 2005 Author Share Posted November 16, 2005 I was doing some more searcing around and I was looking around in the help file at the example code for the send and recv functions. Now the server client setup works only because the server and client communicate that they are closing. I would think that if the client crashed thent he server would be stuck and would not be accecable. So does this mean that there isn't any way ot monitor the socket itself to see that status of the socket whether are connections pending, someone connected, or no one? I suppose you could code a command time lapse socket release but I was wondering if anyone knows a better way? ~Dark Link to comment Share on other sites More sharing options...
DarkNecromancer Posted November 16, 2005 Author Share Posted November 16, 2005 OO thanks, I will check it out Link to comment Share on other sites More sharing options...
DarkNecromancer Posted November 16, 2005 Author Share Posted November 16, 2005 Hmm maybe I'm missing something but I change the server code to Else $socket = TCPAccept($MainSocket) TCPRecv( $socket, 1024 ) $err = @Error EndIf SplashTextOn( "Result", "Main Socket State: " & $MainSocket & @CRLF & "Socket state: " & $socket & @CRLF & "@Error Value" & $err) Sleep(1000) and @Error is -1 while not connected, changes to 0 when the client connects, but stays 0 even after the client disconnects. I have the latest autoit beta so i guess i can just transmit a termination code and just hope no 'weird stuff' happens Link to comment Share on other sites More sharing options...
DarkNecromancer Posted November 17, 2005 Author Share Posted November 17, 2005 Does anyone have any working server client code?? cause I need this for a school project or i'm going to have to write it in C. ~Dark 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