SFML community forums
Help => Network => Topic started by: lorence30 on October 26, 2015, 07:59:52 pm
-
is it possible to a multiple sockets to connect to a single port simultaneously?
-
If I it's what I think you're trying to ask, then the answer is no.
-
sorry for the late reply, this is what i mean
sf::TcpListener listen;
listen.listen(5000);
sf::TcpSocket client1;
sf::TcpSocket client2;
client1.connect("192.168.1.101",5000); // successfully connected
client2.connect("192.168.1.101",5000); // failed to connect
but when i accept first the client1 from the server the client2 doesnt get any problem
client1.connect("192.168.1.101",5000); // successfully connected
listen.accept(client1);
client2.connect("192.168.1.101",5000); // successfully connected
listen.accept(client2);
-
Yes. Multiple clients can connect to the same listening socket. If this was not the case how would you have webservers dealing with thousands of browsers connecting to them on port 80 at the same time?
You just need to accept all connections and handle them; either on the same thread/process, multiple threads, multiple processes or whatever. It's perfectly doable.
-
If this was not the case how would you have webservers dealing with thousands of browsers connecting to them on port 80 at the same time?
this makes sense, i didnt think of this thanks guys :)