Error 10060



Hi,

I have two programs, one a server program and the other client. If i run
both the programs on the same machine evrything works fine, but if i run the
programs on two different machines then i get this error 10060, which is
connection timed out. am not able to fix the problem. pl help..

thank you.


btw the code snippets are:



server.cpp



#include "stdafx.h"

#include "server.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#endif

#include <iostream>

#include "afxsock.h"

#include "afx.h"

#include "winsock2.h"

#include "string.h"

#include "conio.h"







// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])

{

int nRetCode = 0;

// initialize MFC and print and error on failure

if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))

{

// TODO: change error code to suit your needs

_tprintf(_T("Fatal Error: MFC initialization failed\n"));

nRetCode = 1;

}

else

{

CSocket servsock,temp;

sockaddr_in sa;

WSADATA wsadata;

if (WSAStartup(2,&wsadata))

{

cout << "cant startup" ;

getch();

}

LPHOSTENT hp;

hp = gethostbyname("blrk0b3d");


if (hp == NULL)

{

int x;

x = GetLastError();

cout << x;

cout << "no such server";

getch();

}


sa.sin_addr = *((LPIN_ADDR)*hp->h_addr_list);

sa.sin_family = AF_INET;

sa.sin_port = htons (1000);


cout << hp->h_name << '\n';

cout << hp->h_addr_list;

if (!servsock.Create(1000,SOCK_STREAM,"127.0.0.1"))

{

cout << "cant create";

getch();

}



if (!servsock.Listen(5))

{

cout << "cant listen";

getch();

}

cout << "waiting for a connection";

if (!servsock.Accept(temp))

{

cout << "cant accept";

getch();

}

temp.Send("hi",2,0);

temp.Close();

getch();


}

return nRetCode;

}



and the client program is:



#include "stdafx.h"

#include "socket2.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#endif

#include <iostream>

#include "afxsock.h"

#include "afx.h"

#include "winsock2.h"

#include "string.h"

#include "conio.h"

// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])

{

int nRetCode = 0;

// initialize MFC and print and error on failure

if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))

{

// TODO: change error code to suit your needs

_tprintf(_T("Fatal Error: MFC initialization failed\n"));

nRetCode = 1;

}

else

{

char recvbuffer[4] = "";

CSocket clientsock;

WSADATA wsadata;

//hostent * hp;

sockaddr_in sa;



if (WSAStartup(2,&wsadata))

{

cout << "cant startup" ;

getch();

}

//hp = gethostbyaddr(serv_addr,sizeof(serv_addr),AF_INET);

//hp = gethostbyname("blrk0b3d");

LPHOSTENT hp;

hp = gethostbyname("blrk0b3d"); // blrk0b3d id the computer name;


if (hp == NULL)

{

int x;

x = GetLastError();

cout << x;

cout << "no such server";

getch();

}


sa.sin_addr = *((LPIN_ADDR)*hp->h_addr_list);

sa.sin_family = AF_INET;

sa.sin_port = htons (1000);


cout << hp->h_name << '\n';

cout << hp->h_addr_list;


if (!clientsock.Create(0,SOCK_STREAM,"127.0.0.1"))

{

cout << "cant create";

getch();

}

if(!clientsock.Connect((sockaddr *)&sa,sizeof(sockaddr)))

{

cout << "cant connect";

int x;

x = GetLastError(); // here is the error.. which says connection timed out..
error :WSAETIMEDOUT

cout <<x;

getch();

}

clientsock.Receive(recvbuffer,4,0);

cout << recvbuffer;getch();

clientsock.ShutDown();

clientsock.Close();


// TODO: code your application's behavior here.

}

return nRetCode;

}



.



Relevant Pages

  • problem with the udp socket
    ... The sockets are created and I am able to bind also both the client and the ... server apps to the port and the ethereal shows that data is being transferred ... int s, i, slen=sizeof; ... WSADATA wsaData; ...
    (microsoft.public.pocketpc.developer.networking)
  • [NT] Dark Age of Camelot Man-In-The-Middle
    ... use of RSA public key cryptography and an RC4 based symmetric algorithm. ... Seeing the imminent release of code for cracking the game client (which ... At the beginning of each TCP session, the server sends a 1536 bit RSA ... void bytes_out(unsigned char *data, int len) ...
    (Securiteam)
  • up-imapproxy DoS vulnerabilities
    ... up-imapproxy is an IMAP proxy which keeps connections open after client has ... and reuses it when client connects back. ... There are various bugs in up-imapproxy which can crash it. ... unsigned int ReadBytesProcessed; /* bytes already processed in read buf */ ...
    (Bugtraq)
  • Re: Problem with SslStream when using Windows Vista
    ... The code for the server & client follow. ... private int _port = 0; ... // SslStream using the client's network stream. ...
    (microsoft.public.dotnet.framework)
  • [UNIX] Multiple up-imapproxy DoS Vulnerabilities
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... connections open after client has logged out, ... allows attacker to cause the server to crash by sending them when they ... extern void HandleRequest(int); ...
    (Securiteam)