Archived

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

multiple sockets

This topic is 5095 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

The choice of data structures to hold socket descriptors isn''t as important and is dependant on how you plan to use them; single-threaded vs multi-threaded and blocking vs non-blocking vs asynchronous.

Share this post


Link to post
Share on other sites
My current implementation was to create a class that contained a blocking/non-blocking socket and methods that each socket would use. What I''ve done is to create them in an std::vector

I just wondered if anyone had better ideas.

Share this post


Link to post
Share on other sites
ok, what I''ve done is to create a vector called conx of type SesSocket (where SesSocket is a class that holds various winsock related commands) such that it holds all the connections that are created.

conx.push_back(SesSocket(port));
std::vector::iterator itr = conx.begin();
itr->setBlocking(0,false);
itr->acceptSession();
std::cout << itr->uPort << std::endl;


The above code is a brief version of what I''ve used to attempt this, and includes some debugging information.

Out of that code the following lines do not work:
itr->setBlocking(0,false);
itr->acceptSession();


Though the line that prints the variable called uPort does work, which means that a SesSocket is pushed onto the vector, though for some reason the Winsock related commands do not.

The code for setBlocking() and acceptSession() have been tested outside the vector and work fine.


Does anyone have any idea what is causing this and how it might be fixed?

Share this post


Link to post
Share on other sites