I have a tcp server application on windows (c#) wich accepts any connection by the port 3000 I have a tcp client application on linux(ubuntu)(c++) wich send a simple text by the port 3000
I also have a client on windows and a server on linux, i works perfectly sending the text: from linux to linux from windows to windows from windows to linux
the problem is that when i try to send from linux client to windows server my c++ application on linux tells me that the host doesn't exist
i already check the ip adress and it is correct i also tried to do it with hostname
but it doesn't work
does anybody know why it happens???
this is my code on the client(linux-c++):
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=gethostbyname(argv[1]);
server = gethostbyaddr((char *) &addr, 4, AF_INET);
if (server == NULL) {
fprintf(stderr,"ERROR, no such host\n");
exit(0);
}
i call ping and everything is ok
I run my server on windows and open port 3000 to any conection
I try to run my client(code above) with the windowsIP/windowsHostName and the port 3000(Already tried another port)
and the problem is in the line:
server = gethostbyaddr((char *) &addr, 4, AF_INET);
server gets null so it prints "ERROR, no such host"
but the ip is correct.
When i use the same code for conecting with a server on linux(c++) it works