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

Author Topic: socket.bind() Always Fails [SOLVED]  (Read 1813 times)

0 Members and 1 Guest are viewing this topic.

Strikerklm96

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
socket.bind() Always Fails [SOLVED]
« on: March 03, 2014, 03:48:25 am »
This says the error message EVERY time, even when it is successful.
            cout << "\nEnter Receiving Port";
            cin >> RECEIVE_PORT;
            socket.unbind();
            if (!socket.bind(RECEIVE_PORT))
            {
                cout << "\nThere was an error binding to [" << RECEIVE_PORT << "]";
            }

For instance, if I say tell it to bind to 5000, it will say it has failed, but I call socket.getLocalPort(), and it says 5000, AND I can call socket.receive(rPacket, sizeof(rPacket), sizet, RECEIVE_IP, RECEIVE_PORT) and it returns success.
So everything works, except that it claims it doesn't. What's going on?
« Last Edit: March 05, 2014, 05:54:07 pm by Strikerklm96 »

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: socket.bind() Always Fails
« Reply #1 on: March 03, 2014, 06:37:23 am »
bind returns an sf::Socket::Status

Strikerklm96

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: socket.bind() Always Fails
« Reply #2 on: March 03, 2014, 06:34:03 pm »
My bad, I was using a 1.6 tutorial with 2.0. I knew I was doing it, but I was just adjust accordingly because I didn't see there was a 2.0 tutorial for this.
socket.bind(RECEIVE_PORT) != sf::Socket::Done
« Last Edit: March 03, 2014, 06:38:45 pm by Strikerklm96 »