Jump to content

TCP trouble


Recommended Posts

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
Link to comment
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.

Link to comment
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?)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...