Advertisement

UDP disconnect ?

Started by May 18, 2002 03:14 PM
2 comments, last by FearedPixel 22 years, 8 months ago
MSDN says that "If the connection has been gracefully closed, the return value is zero" for recvfrom. When exactly does this happen ? When program on the other end has been closed ? Or when a certain time has passed without packets ? I know UDP is connectionless, so I didnt know it could close some kind of connection, when i thought there isnt one. [edited by - FearedPixel on May 18, 2002 4:15:42 PM]
recvfrom isn''t used exclusively with UDP. The zero return value is only meaningful for for ''connected'' sockets.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
I see.

So in that case, to detect if a user abnormally disconnected (due to program crash or connection etc), I have to constantly check the time since the last packet from the user, and if the time goes over say 30 seconds, then consider the user timed out. Right ?

Is there not an easier way by any chance ?
Don''t think there''s an ''easy'' way, whats so hard about it anyway?

I''d go for longer than 30 seconds before timeout tho.

This topic is closed to new replies.

Advertisement