Solved

Allocating Mulitple Sockets

Posted on 1998-12-27
8
209 Views
Last Modified: 2010-04-02
I am having a problem allocating multiples sockets using win98, and Visual C++ 5.0.  I am using the CAsyncSocket class.  The problem is I get the WASENOBUFS error message after allocating about 255 sockets.  I have tried the solutions by JHance, can anyone else give something that will work?
0
Comment
Question by:Fredbarnes
[X]
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
  • 5
  • 3
8 Comments
 

Author Comment

by:Fredbarnes
ID: 1181114
I have searched high and low for this solution. I am losing hair, and dreaming sockets. Can anyone help? An alternative question is how can I us CAsyncSocket to listen on ALL ports for incoming connections or requests? Is there a way that I can rotate the allocated listening ports to listen on other ports in the background?  JHance? Anyone?
0
 

Author Comment

by:Fredbarnes
ID: 1181115
Adjusted points to 75
0
 

Accepted Solution

by:
dmcreyno earned 70 total points
ID: 1181116
The system is out of buffers for sockets. You have hit the OS limit. Many operating systems place a cap on the number of sockets a process may own. 255 is a popular number.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Fredbarnes
ID: 1181117
I appreciate your answer, and it is decent, however, I would like to know if there is any code available to alternate the 255 sockets, so that I may listen on all ports?  If so, please respond?
0
 

Expert Comment

by:dmcreyno
ID: 1181118
Just out of curiosity, how much memory does this box have? I have compiled a small test app that I got to open 3975 CAsyncSockets. All I do is call Create(). What are your args to Create() so that I might duplicate your lower number?
0
 

Expert Comment

by:dmcreyno
ID: 1181119
Just out of curiosity, how much memory does this box have? I have compiled a small test app that I got to open 3975 CAsyncSockets before I get the WSAENOBUFS. All I do is call Create(). What are your args to Create() so that I might duplicate your lower number? I even had trouble submitting this update while the test app was running. Netscape complained that there were no more sockets.

What are you building that you need to listen to ALL ports. From my own personal experience some OSes will not let you bind below 1024.
0
 

Author Comment

by:Fredbarnes
ID: 1181120
The code I am using is:
int i=1024;
CMySocket* pSocket[65536];

while(i++ <= 65535)
{
 pSocket[i]=new CMySocket;
 if(!pSocket[i]);
{
 MessageBeep(0);
}
//otherwise create the socket;
if(! pSocket[i]->Create(i))
{int err= WSAEGetLastError();
 //print out the error code here.
}
//otherwise listen on that port

//and add the port to CTypedPtrArray structure.
}



0
 

Author Comment

by:Fredbarnes
ID: 1181121
What I am working on is a Proggie called "SneakyPete".  SneakyPete will listen on all ports for incoming requests, while running other apps, like: AIM, AOL, and also Web programs like the IGZ (Internet Gaming Zone).  When IM's are sent, I would like to b able to retrieve the senders IP. It is a security type application.  I have 64 megs of ram (EDO) in the system, it is a 166mmx system In addition, I have lots of devices like cams, DVD, Radio, TV, Scanners... hooked up. If u can help, it would b greatly appreciated.  I am now putting together an old piece of machinery to test on that.  If I get more, then I will reset this system with 255 socket limitation.
Thank you much for your help!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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