Re: Why TCP ECHO Not Work between distant Hosts?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



june schrieb:

Hi! I'm June.
This time I have this question:
TCP ECHO works well if I run both TCPServer.EXE and TCPClient.EXE in
the same computer.

[...]
Then TCPClient.EXE says "connect() error!"

What is wrong? I'd be grateful if you tell me:p

Why don't you ask your operating system, it has answers. Just ask it!

From the documentation of connect():

"If no error occurs, connect returns zero. Otherwise, it returns SOCKET_ERROR, and a specific error code can be retrieved by calling WSAGetLastError."

Did you call WSAGetLastError? Obiously not.

[code deleted]

void ErrorHandling(char *message)
{
fputs(message, stderr);
fputc('\n', stderr);
exit(1);
}
*****
Improve your "ErrorHandling" to do some error handing. The least you can do is read the error code with the help of WASGetLastError(), and print the code to the console. Then you can find the error text using the Error Lookup utility from your compiler.

Better yet, call the "get the error text from error code" function that Joseph Newcomer has posted several times on this list.

BTW, I assume you have the windows firewall active on your server computer, and this is blocking access from the client PC.

Norbert

.



Relevant Pages

  • Re: deamonizing a program in Unix
    ... > error code on failure. ... early in mainbefore opening sockets and other initial processing. ... Perhaps you could leave stdout and stderr as is for error reporting during ... and then later close and reopen stdout and stderr to /dev/null. ...
    (comp.unix.programmer)
  • Re: Problem with UDP socket select
    ... error but it didn't returned any error code. ... "Igor Tandetnik" wrote: ... >> Now the problem is if the remote party is not there to listen then ... > SOCKET_ERROR, what does WSAGetLastError return? ...
    (microsoft.public.vc.language)
  • Re: Error Handling
    ... "J French" wrote: ... > I expect you are right about WSAGetLastError being a front for ... > GetLastError ... > The error code looks right: ...
    (microsoft.public.vb.winapi)
  • WSAError returns 2
    ... WSAGetLastError() returns 2. ... This is not a Winsock-specific error code, ... Am I correct that this is the interpretation that should be given to this ...
    (microsoft.public.win32.programmer.networks)