Jump to content
  • Advertisement
Sign in to follow this  
Wickeeed

fast question about tcp

This topic is 5099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, i want to know how to check a tcp socket that dont have any data to read for errors. that is a problem for me cuz i use gametutorials-like-server-system, with FD_SET and select. my problem is that when a client is gone without "bye" message, how can i find him?? i guess i shuld get an error or something ? how can i check sockets in FD_SET for errors like this ???

Share this post


Link to post
Share on other sites
Advertisement
well, if a client disconnects, you get a READ-event in select(). Then when you read from the socket, it returns a read of 0 bytes.

(it's the same if you try to write to the socket and write() or send() returns 0 - it means that the connection is closed)

is this what you were asking for?

Share this post


Link to post
Share on other sites
thx, looks tike that, connect from server to client is closed but connect from client to server is still there and WAITING (1min long i guess), whys that ? it isnt a big problem but i cant use this port while its waiting.

i guess connection from client to server shuld be closed first because it used closesocket first??

Share this post


Link to post
Share on other sites
If the socket is ready, and reading from it returns 0 bytes, that means the socket is closed.

If reading or writing to the socket returns an error other than EINTR or EWOULDBLOCK (Usually connection reset by peer), that means something has gone wrong.

In that case you should close the socket and release the client's resources. The socket is not usable after any error has occurred.

Mark

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!