Varifying Socket Connection :: Winsock
Hi.
I was wonder about the best way to varify if a socket is currently active. In other words, I need a way to determine if there is a connect on a socket. This is just for command update UI. Basically, if the socket is active, I enable/disable something. If not, I enable/disble something.
How about this code?
// if (mysocket == WSAENOSOCKET)
// socket is invalid or inactive
Thanks,
Kuphryn
It''s connected until you get told it''s disconnected, or until you disconnect it yourself. That would usually be because send or something returned an error value. You can''t just compare the socket descriptor with an error value. It''s not going to magically change the socket number for you.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]
May 11, 2002 12:39 PM
You get to see if someone is disconnected by using send or sendto to the person if it fails then you can''t reach the person. Check the return value for this. You can use select to check if the client are ready to send/recieve or if they have some error.
The first listener you created can be used to check for incoming messages. Make sure that you allow the port to be reused.
The first listener you created can be used to check for incoming messages. Make sure that you allow the port to be reused.
Okay. Thanks.
Nish [BusterBoy] posted a solution using two API functions.
Here is a link to the solution I mentioned.
http://www.codeproject.com/script/c...8001#xx178001xx
johnnie2 posted a different solution using a similar approach to setting pointers to NULL.
Here is a link to the code I mentioned.
http://www.cprogramming.com/cboard/showthread.php?s=b3cf15b75e3287ca197b18fc2d335361&postid=111612#post111612
Kuphryn
Nish [BusterBoy] posted a solution using two API functions.
Here is a link to the solution I mentioned.
http://www.codeproject.com/script/c...8001#xx178001xx
johnnie2 posted a different solution using a similar approach to setting pointers to NULL.
Here is a link to the code I mentioned.
http://www.cprogramming.com/cboard/showthread.php?s=b3cf15b75e3287ca197b18fc2d335361&postid=111612#post111612
Kuphryn
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement