Possible Duplicate:
Connection from linux to windows via tcp
I have a TCP client on windows/c# and another one on linux/c++ Also I have a TCP server on both.
My TCP client on windows/c# works ok, the problem is the TCP client on linux/c++
when I connect to a TCP server on linux/c++ it works perfectly, but when i try to connect to a TCP server on windows/c# it doesn't connect, but the ping is ok.
this is the part of the code where it fails:
int sockfd, portno, n;
struct sockaddr_in serv_addr;
struct hostent *server;
struct in_addr addr={0};
char buffer[256];
if (argc < 3) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[2]);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
addr.s_addr=inet_addr(argv[1]);
server = gethostbyaddr((char *) &addr, 6, AF_INET);
if (server == NULL) {
fprintf(stderr,"ERROR, no such host\n");
exit(0);
the problem is the line:
server = gethostbyaddr((char *) &addr, 6, AF_INET);
it returns null, so it prints "ERROR,no such host"
I have tried every combination:
-TCP client(linux) to TCP Server(linux)
-TCP client(linux) to TCP Server(windows)
-TCP client(windows) to TCP Server(linux)
-TCP client(windows) to TCP Server(windows)
and everything works except: TCP client(linux) to TCP server(windows)
I also tried the TCP client netcat(included on linux) to TCP server(windows) and it works.
I have called ping both from windows to linux and also from linux to windows, and it recieves 100%
I don't know why my TCP client(linux) doesn't connect to TCP server(linux)