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
}