Solved

Allocating Mulitple Sockets

Posted on 1998-12-27
8
198 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
  • 5
  • 3
8 Comments
 

Author Comment

by:Fredbarnes
Comment Utility
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
Comment Utility
Adjusted points to 75
0
 

Accepted Solution

by:
dmcreyno earned 70 total points
Comment Utility
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
 

Author Comment

by:Fredbarnes
Comment Utility
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
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

 

Expert Comment

by:dmcreyno
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

728 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

9 Experts available now in Live!

Get 1:1 Help Now