0

I have a client and server written with MFC using Winsock. They only work when they are on the same computer(i.e. "127.0.0.1") but once I attempt to connect the a client from a different computer I receive error code 10060 which is a TimeOut Error. I'm not sure if this is relevant but, one computer is connected to a domain(it's a school computer) and the other is under a workgroup so not sure if those are causing issues. Here is some code, the server objects are linked to a class I derived from CSocket.

Client

if(client.Create() != true)
    AfxMessageBox(L"FAILED");

UINT port = 200;    
client.Connect(L"IP ADDRESS",port); //fails here
int msg = client.GetLastError();
CString c_msg;
c_msg.Format(L"%d",msg);
AfxMessageBox(c_msg); //displays error code

Server

int i_port = 80;
server.Bind(server.Create(0,SOCK_STREAM,NULL)); // saw somewhere that i should bind the socket

if(server.Listen() == false)// if listen() fails
{
    AfxMessageBox(L"Could not Listen on specified Port \n Please select a different one.");
    server.Close();// close server
}
c_List.AddString(L"Server Listening");// notfiy user server is listening in ListBox

Server Accept function

CString userIp; //string
CString u_Status("Connection made from IP Address:"); //string
UINT userPort = 0; //integer

if(server.Accept(client))// if server sucessfully accepts client then
{
    client.GetSockName(userIp,userPort); // get client IP and Port number and assign to variables
    u_Status = u_Status + userIp; // string additon


    ListStatus = u_Status; // assigning local value to global string
    conIp = true; // change boolean to true

}
user1704863
  • 394
  • 1
  • 6
  • 19
  • Have you tried to ping the server from the client? You can do that from the Windows command prompt using the ping xxx.xxx.xxx.xxx command. If it won't respond to ping then the network routers will not let you connect. – ScottMcP-MVP Jul 16 '13 at 04:27
  • Sounds like a firewall issue to me. Have you tried switching off firewall just to test? – snowdude Jul 16 '13 at 09:33
  • @ScottMcP-MVP I tried to ping the server but I it fails with timeouts as well, I can't ping any computer on the same network. As for turning of the firewall. One of the PC's is registered to a domain network so they've disabled the ability to turn off the firewall. – user1704863 Jul 16 '13 at 20:40

0 Answers0