Solved

Allocating Mulitple Sockets

Posted on 1998-12-27
8
205 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
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dialogbox API leak? 18 99
Which Linux flavors will this run on? 6 96
c++ reading data from file into two dimensional array 3 117
Need some help with mailto 16 20
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

831 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