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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Live4Pie

Pages: [1]
1
Network / Recuperating IP Address from selector
« on: September 09, 2009, 01:15:07 am »
Thank you for the rapid responses.

That was what I was thinking of doing, just making sure there is nothing I'm overlooking that would save me some time.

Again, thank you for the answers

2
Network / Recuperating IP Address from selector
« on: September 08, 2009, 02:34:37 am »
Hello, I am using the SelectorTCP for a basic multi-client server, and a fairly important problem arises when it's time to process the information the client sends : I cannot determine from which client the information arrives.

My question is, how would you go about recuperating the IP address from the SocketTCP?

Code: [Select]


    sf::SocketTCP Socket = Selector.GetSocketReady(i);

    if (Socket == Listener)
    {
        sf::IPAddress Address;
        sf::SocketTCP Client;
        Listener.Accept(Client, &Address);
        std::cout << "Client connected ! (" << Address << ")" << std::endl;

        //I get that the address of the Client is in Address at this point, but this doesn't solve the issue that arises when he sends information later on
        Selector.Add(Client);
    }
    else
    {

        sf::Packet Packet;
        if (Socket.Receive(Packet) == sf::Socket::Done)
        {
//This is where i'd like to know the IP of the client who just sent the message, so I can send it back to the rest of the program
            std::string Message;
            Packet >> Message;
            std::cout << "A client says : \"" << Message << "\"" << std::endl;

        }
        else
        {
            Selector.Remove(Socket);
        }
    }


Thank you for any help or advice.

Pages: [1]