Sign in to follow this  
Followers 0
mladost1

TCP trouble

4 posts in this topic

I've been doing some playing with the TCP and i was curious how to know when the client has ended the connection? And how should the server start looking for a new one again?

$mainSocket=TCPListen($server,512)

while 1
   if $connectedSocket=-1 then
      $connectedSocket=TCPAccept($mainSocket)
   endif
  ;however if I add a $mainSocket=TCPListen($server,512) to check if there is an incomming connection, the entire thing fails to connect
wend

Share this post


Link to post
Share on other sites



If the client has ended the connection, functions such as TPCRecv and TCPSend will fail. You can use this to determine if the connection has been closed, and then you can go back to using TCPAccept, howerver it is not needed or usefull to use TCPListen again.

Share this post


Link to post
Share on other sites

Yea the TCPAccept function only needs to change, it works, thanks. What about the same thing but from the side of the client( e.g. the server restarts and the client script needs to find that out and reestablish a connection?)

Share this post


Link to post
Share on other sites

should i recreate the TCPConnect socket?

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  
Followers 0