gethostbyname blocked at execution time
vitry
vitry.es at gmail.com
Tue Jun 30 05:55:29 UTC 2009
Hi to all,
I'm try to run a very simple test program with sockets and it's blocked
in gethostbyname function. I think that perhaps the previous mallocs
functions create some problem that i don't understand and I prefer to
coment it with you for some help.
The litle code is the next:
#includes ...
int main(int argc, char **argv)
{
struct sockaddr_in dir_socket_C;
struct sockaddr_in dir_socket_S;
struct sockaddr_in dir_socket_R;
char * name_host_S;
char * name_host_C;
struct hostent *info_host_S;
struct hostent *info_host_C;
struct in_addr ** addr_host_S;
struct in_addr ** addr_host_C;
int size,i,sock,t;
name_host_S= (char *) malloc (sizeof(char)*50);
info_host_S= (struct hostent *) malloc (sizeof(struct hostent));
addr_host_S= (struct in_addr **) malloc (sizeof(struct in_addr)*10);
name_host_C= (char *) malloc (sizeof(char)*50);
info_host_C= (struct hostent *) malloc (sizeof(struct hostent));
addr_host_C= (struct in_addr **) malloc (sizeof(struct in_addr)*10);
if ((sock=socket(AF_INET,SOCK_STREAM,0))==-1) exit(1);
if ((t=gethostname((char *)name_host_C,MAXHOSTNAMELEN))==-1) exit(2);
if ((info_host_C=gethostbyname((char *)name_host_C))==NULL) exit(3);
// and in this point the execution is blocked !!
Thks a lot in advance for any suggestion ,
vitry
More information about the uClibc
mailing list