Link to home
Start Free TrialLog in
Avatar of Fredbarnes
Fredbarnes

asked on

Allocating Mulitple Sockets

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?
Avatar of Fredbarnes
Fredbarnes

ASKER

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?
Adjusted points to 75
ASKER CERTIFIED SOLUTION
Avatar of dmcreyno
dmcreyno

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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?
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.
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.
}



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!