please help me. What is problem with my code? It don't work at all. Please give me some advice. My aim is to get some information from whois server (from whois.nic.cz). Here is my code, which don't work (it gives no entry in whois server):
I have simplified code to minimum, but it still don't work (for example direct value in functions)
#include<stdio.h> //scanf , printf
#include<string.h> //strtok
#include<stdlib.h> //realloc
#include<sys/socket.h> //socket
#include<netinet/in.h> //sockaddr_in
#include<arpa/inet.h> //getsockname
#include<netdb.h> //hostent
#include<unistd.h> //close
int main(int argc , char *argv[]){
char buffer[5000];
int sock , size = 0;
struct sockaddr_in dest;
sock = socket(AF_INET , SOCK_STREAM , 0);
memset( &dest , 0 , sizeof(dest) );
dest.sin_family = AF_INET;
dest.sin_addr.s_addr = inet_addr("217.31.205.42");
dest.sin_port = htons(43);
if(connect( sock , (const struct sockaddr*) &dest , sizeof(dest) ) < 0)
{
perror("connect failed");
}
if( send(sock , "77.75.75.176\r\n" , strlen("77.75.75.176\r\n") , 0) < 0)
{
perror("send failed");
}
printf("HERE\n");
size = recv(sock , buffer , sizeof(buffer) , 0);
printf("HERE\n");
printf("size:%dBUFFER:\n%s\n", size, buffer);
fflush(stdout);
close(sock);
return 0;
}
I expected some result from whois server, but it gives no entry in whois server