bnhshallow
Programmer
I am trying to make a connection between a client and server. Both are running on my machine and I am using loopback, but for some reason the client wont connect.
Here is my code for the client:
When I try to connect to the server, I get the "Connection Failed" error message.
Here is my server code just incase you need it:
I have tried sevral different things and havn't been able to connect. Can anyone tell me what I am doing wrong?
Thanks,
BNHShallow
Here is my code for the client:
Code:
void CSocketsDlg::OnOK()
{
CString IpName;
GetDlgItem(IDC_IP) -> SetWindowText(IpName);
if(m_sMySocket.Create())
{}
else
{MessageBox("Socket Failed");}
if(m_sMySocket.Connect(IpName, 4000))
{GetDlgItem(IDC_STAT) -> SetWindowText("Connection Made Successfully");}
else
{GetDlgItem(IDC_STAT) -> SetWindowText("Connection Failed");}
m_sMySocket.Close();
}
When I try to connect to the server, I get the "Connection Failed" error message.
Here is my server code just incase you need it:
Code:
void CServerDlg::OnOK()
{
m_sMySocket.Create(4000);
if(m_sMySocket.Listen())
{GetDlgItem(IDC_STAT) -> SetWindowText("Listen Command Successful");}
else
{GetDlgItem(IDC_STAT) -> SetWindowText("Listen Failed");}
}
void CServerDlg::OnAccept()
{
if(m_sMySocket.Accept(m_sMySocket2))
{GetDlgItem(IDC_STAT) -> SetWindowText("Accept Successful");
MessageBox("Connection Made!");}
else
{GetDlgItem(IDC_STAT) -> SetWindowText("Accept Failed");}
}
I have tried sevral different things and havn't been able to connect. Can anyone tell me what I am doing wrong?
Thanks,
BNHShallow