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

Author Topic: Socket Accept method arguments  (Read 2128 times)

0 Members and 1 Guest are viewing this topic.

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Socket Accept method arguments
« on: April 26, 2011, 07:26:53 pm »
Hi everyone,

I have a question regarding the SocketTCP::Accept method:

Why do I have to pass a SocketTCP object, why it doesen't just work on the *this object?
(Why) do I need more than one socket object?


Quote

Socket::Status sf::SocketTCP::Accept    (   SocketTCP &    Connected,
      IPAddress *    Address = NULL   
   )         


 Wait for a connection (must be listening to a port).

 This function will block if the socket is blocking

Parameters:   Connected    : Socket containing the connection with the connected client
   Address    : Pointer to an address to fill with client infos (NULL by default)

Returns:
Status code
 This function will block if the socket is blocking

Definition at line 195 of file SocketTCP.cpp.


Do I really need more than 1 socket object for just receiving or just sending (not both)?

I don't really understand this method and why it has this signature...
Please help me :-)

BTW: Great thx for your help Laurent (in several other threads).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Socket Accept method arguments
« Reply #1 on: April 26, 2011, 07:33:43 pm »
Accept returns a new socket, which is the connection with the client that just connected. The listener will continue to listen to incoming connections, you must use the new socket for communicating with the new client.
Laurent Gomila - SFML developer

 

anything