user3796535
user3796535

Reputation: 25

port of connected client in sfml

i do not understand how (tcp-)ports work ( in sfml ).

From my understanding a sf::TcpListener is a sf::TcpSocket that can not really send or receive data except for accepting connections.

Let's assume i have multiple listeners on different ports: think of them like clients for my game (first port) and a config-tool (second port) which i'm writing right now.

I'd like to handle sf::Packets differently depending on which port i received them.

But here is the problem: I don't know how the connect works, but i guess it must assign a different port ( otherwise i would have two clients both running on localhost connected to the same port). so i cannot switch on the port anymore.

Any help is much appreciated.

Upvotes: 0

Views: 358

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409414

You have two different sf::TcpListener objects. You check for connections on the first listener object, and put those connections in one collection. Then you check for connections on the second listener object, and put those connections in a second collection.

That way the connections are separate, and can therefore be handled accordingly.

Upvotes: 1

Related Questions