WSAENOBUFS error - TCP-IP

This is a discussion on WSAENOBUFS error - TCP-IP ; Hello. I have an application that uses TCP Sockects to see if a port is alive or dead. For this I use a thread for every TCP-Ping that I do. In each thread I open a socket and try to ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: WSAENOBUFS error

  1. WSAENOBUFS error

    Hello.

    I have an application that uses TCP Sockects to see if a port is alive
    or dead.
    For this I use a thread for every TCP-Ping that I do.
    In each thread I open a socket and try to execute a blocking Connect
    command.
    I test this application on a list of 2000 IP:Port devices
    The application tries this TCP-Ping for all these devices in every 10
    minutes.
    After about 6 hours, on every Connect attempt I get the WSAENOBUFS
    error.
    Also my computer seems to stuck.
    Only if I kill the aplications process - the computer recovers and I
    can run this aplication again for another 6 hours.

    I tried almost everything to change the TCP parameters through the
    registry, and also to kill and free the socket.
    Here is the sample code of the thread:

    WSAStartup( MAKEWORD(2,2), &wsaData );

    m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if ( m_socket == INVALID_SOCKET )
    {
    LogMsg.Format("ERROR socket INVALID_SOCKET: %d", WSAGetLastError());
    WSACleanup();
    hr = E_FAIL;
    return hr;
    }

    clientService.sin_family = AF_INET;
    clientService.sin_addr.s_addr = inet_addr(IpAddress);
    clientService.sin_port = htons(Port);

    // connect the socket to the IP:Port - a blocking connect
    rc = connect(m_socket, (SOCKADDR*) &clientService, sizeof(SOCKADDR));

    if (rc == SOCKET_ERROR)
    {
    LogMsg.Format("ERROR connect SOCKET_ERROR: %d", WSAGetLastError());
    LOG_OUTPUT(LogMsg.GetBuffer());
    hr = E_FAIL;
    }
    else
    {
    hr = S_OK;
    shutdown(m_socket, SD_BOTH);
    }

    CancelIo((HANDLE)m_socket);
    closesocket(m_socket);
    WSACleanup();
    return hr;


    I don't understand why I have this error - it seems like after a
    period of time the TCP buffer is filled although I don't use any TCP
    command that takes TCP buffer (only createSocket and Connect), does
    these commands take TCP buffer? how do I free the buffer?
    After finishing this code, the thread exits.
    I also tried to use the Select, WSAEventSelect, CreateIoCompletionPort
    commands with a non-blocking socket and had the same results.

    Can anyone help me?

  2. Re: WSAENOBUFS error

    On Apr 6, 12:42 am, hares...@gmail.com wrote:

    > I have an application that uses TCP Sockects to see if a port is alive
    > or dead.


    What OS? Windows XP specifically, and by design, cannot do this.

    DS

  3. Re: WSAENOBUFS error

    On Apr 8, 4:14*am, David Schwartz wrote:
    > On Apr 6, 12:42 am, hares...@gmail.com wrote:
    >
    > > I have an application that uses TCP Sockects to see if a port is alive
    > > or dead.

    >
    > What OS? Windows XP specifically, and by design, cannot do this.
    >
    > DS


    Yes it is on Windows XP.

    I have modified allready my TCPIP settings with the EvID4226Patch.exe
    patch, and also added the following registry values:
    "MaxUserPort"=dword:0000fffe
    "TcpTimedWaitDelay"=dword:0000001e
    "StrictTimeWaitSeqCheck"=dword:00000001

    Why it cannot be done?

    Itai


  4. Re: WSAENOBUFS error

    On Apr 7, 10:48 pm, hares...@gmail.com wrote:

    > Why it cannot be done?


    Because Windows XP is specifically designed not to be able to do this.
    I do not agree with the decision, but that's the way it is. The patch
    helps, but it does not solve the underlying problem.

    It may help for you to 'bind' yourself rather than letting the system
    do it for you. It may help to use asynchronous I/O and IOCP.

    But basically, you are fighting the design of the stack. This kind of
    problem is best solved outside of the stack, which is how most tools
    that do this actually work.

    DS

  5. Re: WSAENOBUFS error

    On Apr 8, 7:55*am, David Schwartz wrote:
    > On Apr 7, 10:48 pm, hares...@gmail.com wrote:
    >
    > > Why it cannot be done?

    >
    > Because Windows XP is specifically designed not to be able to do this.
    > I do not agree with the decision, but that's the way it is. The patch
    > helps, but it does not solve the underlying problem.
    >
    > It may help for you to 'bind' yourself rather than letting the system
    > do it for you. It may help to use asynchronous I/O and IOCP.
    >
    > But basically, you are fighting the design of the stack. This kind of
    > problem is best solved outside of the stack, which is how most tools
    > that do this actually work.
    >
    > DS


    Do you have a recomendation of what tool or method should i use?

    Itai

  6. Re: WSAENOBUFS error

    On 07 Apr 2008, David Schwartz wrote:

    > On Apr 7, 10:48 pm, hares...@gmail.com wrote:
    >
    >> Why it cannot be done?

    >
    > Because Windows XP is specifically designed not to be able to do
    > this.


    Sorry for being dense, but could you say exactly what "this" means here
    in general terms and why XP was designed not to be able to do it? Is
    it the number of connections (2000 in the OP) that's the issue?

    Dave

    --
    D.a.v.i.d T.i.k.t.i.n
    t.i.k.t.i.n [at] a.d.v.a.n.c.e.d.r.e.l.a.y [dot] c.o.m

  7. Re: WSAENOBUFS error

    On Apr 9, 8:24 am, David Tiktin wrote:

    > Sorry for being dense, but could you say exactly what "this" means here
    > in general terms and why XP was designed not to be able to do it? Is
    > it the number of connections (2000 in the OP) that's the issue?


    "This" means the ability to attempt large numbers of outbound TCP
    connections in a small period of time. My understanding is that XP was
    originally not designed to be able to do it because it was intended as
    a desktop operating system rather than a server operating system, and
    was further deliberately limited by SP2 as a misguided attempt at a
    security measure.

    DS

  8. Re: WSAENOBUFS error

    In article <08c0d3ed-3957-42b9-9148-02a18c9f4c2c@t54g2000hsg.googlegroups.com>, hareshet@gmail.com writes:

    | Do you have a recomendation of what tool or method should i use?

    You might want to try enabling linger and setting the linger time to
    zero with SO_LINGER (l_onoff = 1; l_linger = 0). I don't know exactly
    how XP counts "concurrent" connections (or even if this is really what
    it limits) but it couldn't hurt to dump the state as quickly as possible.
    (Well, it couldn't hurt you. The other end might not be happy with the
    RST...)

    Dan Lanciani
    ddl@danlan.*com

+ Reply to Thread