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

Author Topic: I'm not quite sure I understand how to use a TCP listener.  (Read 3240 times)

0 Members and 1 Guest are viewing this topic.

MarthKoopa

  • Guest
I'm not quite sure I understand how to use a TCP listener.
« on: August 21, 2010, 11:32:01 pm »
When running this code every loop, not in blocking mode, it should find connections and register them into the vector, right?  Or how else should I do this?

Code: [Select]
if (Listener.Accept(Client, &ClientAddress) != sf::Socket::NotReady)
{
    cout << "Client connecting from " << ClientAddress << endl;
    Client.Ip = ClientAddress;
    Client.SetBlocking(false);
    Clients.push_back(Client);
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
I'm not quite sure I understand how to use a TCP listener.
« Reply #1 on: August 22, 2010, 09:28:00 pm »
Code: [Select]
!= sf::Socket::NotReady
This should be "== sf::Socket::Done", NotReady is not the only failure that can be returned.

Code: [Select]
ServerSocket.Connect(55555, "192.168.1.101")
The Connect function also returns a status code, not a boolean (so it should be checked the same way as above) ;)
Laurent Gomila - SFML developer