Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: selectors socket identification.  (Read 23966 times)

0 Members and 2 Guests are viewing this topic.

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
selectors socket identification.
« on: April 25, 2008, 11:47:02 am »
Is there a way to identify a socket, that is returned by the Selector.GetSocketReady(int i) (as in the current SVN...)
I would like to use the selector in a server.. now the server must know from which Client he got the package (IP is not enought, since there might be more than one client per IP)
one possibility would be to have a seconde array of sockets  and then using == for testing.. but the better one would be to have a unique SocketID or something for each socket in the selector..
Any chance you would add something like this to the selector class? (I even would do the little bit of coding^^
[/code]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
selectors socket identification.
« Reply #1 on: April 25, 2008, 11:57:25 am »
The socket classes are basically just an encapsulation of a unique identifier (the socket handle), so you can perfectly identify a client with its socket. The socket classes have all the comparison operators needed to use them as identifiers (in a std::map for example).
Laurent Gomila - SFML developer

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
selectors socket identification.
« Reply #2 on: April 25, 2008, 12:06:37 pm »
I know.. thats exactly, what I wantet to say with
Quote

one possibility would be to have a seconde array of sockets and then using == for testing..
(though maybe not understandable  :wink: )
so maybe having a map <socket, clientId> is the best Idea, since the sockets only are defined by its handle.. sounds good so far ^^

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
selectors socket identification.
« Reply #3 on: April 25, 2008, 01:12:35 pm »
Yep, that's the typical solution ;)
Laurent Gomila - SFML developer

 

anything