Search
Close this search box.

Winsock error 10035

Winsock error 10035 means “Resource not available” or “Operation would block”. Huh?

This error happens when the winsock buffer of either the client or server side become full. Huh? Ok, let me try to describe it as plainly as possible:

Here are two situations in which you might see Winsock error 10035:

  • You’re trying to send a massive amount of information through the socket, so the output buffer of the system becomes full.
  • You’re trying to send data through the socket to the remotehost, but the remotehost input buffer is full (because its receiving data slower than you’re sending it).

When you send data – you really send it to the TCP/IP subsystem of your machine (ie winsock). The system buffers this data (in the OutBuffer) and begins sending it to the remote host as fast as it can (which of course is only as fast as the receiver can receive it). If the OutBuffer gets filled, because you are sending data faster than the system can send it – you’ll get Winsock error 10035.

For IP*Works! users, you will never have to worry about this error because the components deal with them for you automatically, with the exception of IPPort an IPDaemon, the basic level TCP client and server components. These two components are the building blocks with which you can build any TCP/IP solution, they give you complete control over everything.

In order to deal with this when using IPPort or IPDaemon, just catch the Winsock 10035 error and wait for the component’s ReadyToSend event to fire (this fires when the system is able to send data again). At that time, you can continue sending your data, starting with that which failed. For example (C# – if you need help with other languages let me know), the code below will loop until the length of the data to be sent is 0. If all goes normally, this loop will only be entered once and all of the data will be sent. After a while, if the input buffer fills up, the SetDataToSend inside the loop will fail with the Winsock 10035 error. The code will wait for the ReadyToSend event (the ready boolean flag), and loop. SetDataToSend will be called again, successfully.

while (length > 0) {  // this means that we have some bytes to send
  try {
    ready = false;
    ipport1.SetDataToSend(TextB, offset, length);
    length -= ipport1.BytesSent;
    tbStatus.AppendText(ipport1.BytesSent.ToString() + " bytes sent." + "\r\n");
  } catch (nsoftware.IPWorks.IPWorksException ex1) {
    if (ex1.Code == 135)  // WOULDBLOCK Error
    {
      while (!ready) {
        ipport1.DoEvents();
      }
      length -= ipport1.BytesSent;
      offset += ipport1.BytesSent;
      tbStatus.AppendText("Retrying Send..." + "\r\n");
    }
  }
}

posted on Wednesday, July 20, 2005 8:52 AM

This article is part of the GWB Archives. Original Author: Lance Robinson

Related Posts