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

Author Topic: Can not connect TCP socket (to server)  (Read 4694 times)

0 Members and 1 Guest are viewing this topic.

Uncle_Mike

  • Newbie
  • *
  • Posts: 19
    • View Profile
Can not connect TCP socket (to server)
« on: March 09, 2012, 12:39:43 pm »
Hi.
From my Client application I try connect to my Server application.

Client code:
Code: [Select]

sf::SocketTCP ClientSock;
sf::IPAddress ServerIP;

   ServerIP=sf::IPAddress(123, 456, 123, 456);// for example

if (ClientSock.Connect(4567, ServerIP,5) != sf::Socket::Done)
{
cout << "Client connection to server **** Error ****";
return false;
}
else
{
cout << "Client connection to server OK!";
}


But connection is Error!
What is problem?
Server Listener is ok, and is working properly.
My FireWall is unblocked...

VPellen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Can not connect TCP socket (to server)
« Reply #1 on: March 09, 2012, 01:15:48 pm »
Assuming that's directly copy-pasted:

Code: [Select]
ServerIP=sf::IPAddress(123, 456, 123, 456);// for example

Should probably be

Code: [Select]
ServerIP=sf::IPAddress(127, 0, 0, 1);// Connect to the local host

If you don't know what an IP Address is, it's basically your computer's location on the internet. "127.0.0.1" means "local host" or "this computer".

Uncle_Mike

  • Newbie
  • *
  • Posts: 19
    • View Profile
Can not connect TCP socket (to server)
« Reply #2 on: March 09, 2012, 01:41:44 pm »
No, Server is internet host.
Address is the same as can be get by sf::IPAddress::GetPublicAddress().

VPellen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Can not connect TCP socket (to server)
« Reply #3 on: March 09, 2012, 01:47:20 pm »
Are you running the server and client on the same computer?
Or on the same network?

Uncle_Mike

  • Newbie
  • *
  • Posts: 19
    • View Profile
Can not connect TCP socket (to server)
« Reply #4 on: March 09, 2012, 02:10:38 pm »
No! Of course no! :) There are separate computers, and They are locate in different buildings.

VPellen

  • Newbie
  • *
  • Posts: 14
    • View Profile
Can not connect TCP socket (to server)
« Reply #5 on: March 09, 2012, 02:21:36 pm »
Hmm.

Try running your client app and the server app on the same computer with the server IP being localhost. If that works, then the problem isn't SFML, but rather a router or network issue.

 

anything