Link to home
Start Free TrialLog in
Avatar of VEngineer
VEngineer

asked on

Non-Blocking Winsock Sockets

How can I create a non-blocking socket in VC++ using Winsock (no MFC)?
ASKER CERTIFIED SOLUTION
Avatar of WDB
WDB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WDB
WDB

Or if you need to do this explicitly try:

u_long argp = 1L;
int nRet;
SOCKET s;
.
s = socket(PF_INET,SOCK_DGRAM,0);
if(s==INVALID_SOCKET) // report error

// Make Socket Non-Blocking

nRet = ioctlsocket(s,FIONBIO,(u_long FAR *)&argp);
if(nRet == SOCKET_ERROR) // report error