mladost1 Posted June 23, 2008 Posted June 23, 2008 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
TomZ Posted June 23, 2008 Posted June 23, 2008 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.
mladost1 Posted June 23, 2008 Author Posted June 23, 2008 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?)
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