How to control the connecting time in SOCKET?
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
In my program I need to control the connecting time,which means that when I use connect() to connect another machine,I can set how many seconds before the function return. if u can give me some hint,u will give me a big faver!
Before calling connect, add a call to set the socket up as non-blocking: ULONG ulParam = 1; ioctlsocket(m_hSocket, FIONBIO, &ulParam); Then call connect as normal. After calling connect, you can do a select (writing) with whatever timeout you want to see if the socket has connected - if the socket can be written to it is connected. Regards, Simon