Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kindfluffysteve

winsock limited to 64 connections

This topic is 5868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, I''m programming some kind of game for a uni project and in these forums i come across something about 64 connections are the maximun? can somebody clarify this? I am actually using some sort of wrapper class as I dont know how to use winsock directly. This number of 64 strikes me as being somewhat artificial - how do i get beyond it? I dont need to go beyond it, I''d just like to know how. the game im doing is a racing game. 64 is plenty but i have ideas for other things.

Share this post


Link to post
Share on other sites
Advertisement
It''s a Windows quirk.

from winsock2.h
/*
* Select uses arrays of SOCKETs. These macros manipulate such
* arrays. FD_SETSIZE may be defined by the user before including
* this file, but the default here should be >= 64.
*
* CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
* INCLUDED IN WINSOCK2.H EXACTLY AS SHOWN HERE.
*/
#ifndef FD_SETSIZE
#define FD_SETSIZE 64
#endif /* FD_SETSIZE */

typedef struct fd_set {
u_int fd_count; /* how many are SET? */
SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
} fd_set;


Just put a #define FD_SETSIZE 1024 before #including winsock2.h

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Should be the same for winsock.h yes.
Should be remembered though that FD_SETSIZE is a suggested upper limit, there is no guarantee that your program will actually be able to secure 1024 connection resources from the system...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Still no guarantee So your program shouldn''t rely on absolutely being able to get that number of connections.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oh, btw, the person who said it''s a windows quirk, i''m pretty damn sure that standard berkely sockets has a similar limit also, i''m not sure if it also uses FD_SETSIZE, but i am almost certain it has a limit (that can be redefined).

Share this post


Link to post
Share on other sites
To the last AP, yep you''re correct - it''s a standard UNIX thing that stems from the fact that a socket is really just a type of file to the system. Linux defaults to 1024, as does solaris. Change FD_SETSIZE and it should work up to the limit imposed by system resources (i.e. based on memory availability, the size of the data type representing the socket descriptor, etc.)

Share this post


Link to post
Share on other sites
64/thread? That''s not a sockets limitation. Maybe the style of asynchronous IO notification you are using or something (available Event handles maybe?).

I believe the only thing limiting available sockets in a straight socket app is system resources, and the FD_SETSIZE if you use select(). I frequently run 1000 connections in a single thread using select(), but my FD_SET is never larger than one (I select() sockets individually based on need to read/write).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!