Solved

win32 socket error-10055(WSAENOBUFS)!!!

Posted on 2001-07-17
19
3,450 Views
Last Modified: 2012-05-04
When I run my stress test client program overnight, eventually I got this error (10055) when my client program try to reconnect/send data to the server. From the msdn, it says it is "No buffer space available". what caused this and how to prevent this ?
0
Comment
Question by:eugeneng
  • 10
  • 7
  • 2
19 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 6292753
sounds like you are not freeing resources your client uses, are you closing sockets, freeing memory etc etc.

Paul
0
 

Author Comment

by:eugeneng
ID: 6293108
it is tcp/ip connection, so I don't close socket untill the program exit, or when I need to recreate a new one. Do you mean the machine has run out of memory ?
When this error happen, I have to reboot the computer in order to run the client program again.
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293135
it sounds like you are not closing the connections, if your program creates sockets that connects to servers/hosts then you should close the socket after you have finshed then recreate a new one for further connections

pseudo code

loop
  socket = create socket
  connect address
  use socket
  closesocket socket
end loop

if you really must post the code, if its tons then mail it to me paul_maker@hotmail.com, only bother if its VC++ cos thats all i have at the moment, also do not mail me the debug directory
0
 

Author Comment

by:eugeneng
ID: 6293169
it is tcp/ip connection, so I don't close socket untill the program exit, or when I need to recreate a new one. Do you mean the machine has run out of memory ?
When this error happen, I have to reboot the computer in order to run the client program again.
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293176
double post
0
 

Author Comment

by:eugeneng
ID: 6293189
it is tcp/ip connection, so I don't close socket untill the program exit, or when I need to recreate a new one. Do you mean the machine has run out of memory ?
When this error happen, I have to reboot the computer in order to run the client program again.
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293194
whats up, stop posting the same comment
0
 

Author Comment

by:eugeneng
ID: 6293195
I didn't do anything, why would this happened ?
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293204
errr, EE mess up, it would not be the first time,

anyway back to the problem in hand,

wnat compiler and OS
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:eugeneng
ID: 6293227
this is the code I suppose to post,

bool mySocket::Connect()
{
    if (!m_Opened)
     CreateSocket();
      :
      :
     
     if (connect(m_Handle, (sockaddr *) &Address, sizeof(Address)) == SOCKET_ERROR)
     {
           m_SocketError = WSAGetLastError();
            return false;
     }

bool mySocket::CreateSocket()
{
    Close();
    m_hHandle = socket(PF_INET, SOCK_STREAM, 0);
    if (m_hHandle < 0)
    {
     m_SocketError = WSAGetLastError();
        return false;
    }
    m_Open = true;
    return true;
}

void mySocket::Close(void)
{
  if (m_Open)
 {
   shutdown(m_Handle, 2);
   closesocket(m_Handle);
 }
  m_Open = false;
}


this is my to show how do I create, connect, and close the socket, see I close the existing socket whenever I recreate a new one...

0
 

Author Comment

by:eugeneng
ID: 6293232
I'm using VC++ 6.0 on Win2k
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293278
this will fix it, you should always close it before reconnecting or the old connection will not close but just hang around unreferenced

if(m_Opened)
{
 Close();
}
CreateSocket();
0
 

Author Comment

by:eugeneng
ID: 6293295
I'm using VC++ 6.0 on Win2k
0
 

Author Comment

by:eugeneng
ID: 6293319
I'm using VC++ 6.0 on Win2k
0
 

Author Comment

by:eugeneng
ID: 6293322
I'm using VC++ 6.0 on Win2k
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6294711
from http://www.jsiinc.com/SUBB/tip0900/rh0914.htm
....

An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

Not much better.

If you are trying to use an ephemeral (short-lived) TCP port above 5000, this may explain the message. By default, Windows NT 4.0 only supports 5000 ephemeral TCP ports.

You can increase this by navigating to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

Add Value name MaxUserPort, a type REG_DWORD, and set it to some decimal number in the range of 5000 - 65534.

Once a port is closed, it takes 4 minutes (240 seconds) before the system will reuse it. You can alter this behavior if you

Add Value name TcpTimedWaitDelay as a type REG_DWORD and set it to some decimal number in the range of 30 - 300 seconds.
....
~ same ideas see in
http://www.proxyplus.cz/faq/articles/EN/art10002.htm

may be it helps...
0
 
LVL 10

Expert Comment

by:makerp
ID: 6294735
alex, could you post me that COM example

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=cplusprog&qid=20150920

cheers

i will put the pts up to 100
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 50 total points
ID: 6304565
eugeneng , did you solved your problem with help
of my comment?
0
 

Author Comment

by:eugeneng
ID: 6306891
sorry, AlexVirochovsky, I was busy with other thing else, I don't know whether your comment will solve my problem but at least you gave me some clue on the problem. thank you any way..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

708 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now