Non-Blocking Winsock Sockets

Posted on 1998-07-08
Last Modified: 2013-12-03
How can I create a non-blocking socket in VC++ using Winsock (no MFC)?
Question by:VEngineer
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

WDB earned 10 total points
ID: 1409662
Use This to Create a Non-Blocking Socket

BOOL setSockNonBlocking(HWND hwnd,SOCKET sock)
   int  iStatus;

   if ((iStatus =WSAAsyncSelect(sock,hwnd,WSOCK_MESSAGE,                    FD_CONNECT | FD_READ | FD_CLOSE)) > 0) {
      // report error
      return FALSE;
}  // setSockNonBlocking(HWND,SOCKET)

Expert Comment

ID: 1409663
Or if you need to do this explicitly try:

u_long argp = 1L;
int nRet;
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

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question