I believe you have DNS problems. Try nslookup www.hotmail.com ---- Lev Assinovsky Aelita Software Corporation > -----Original Message----- > From: Andre Kirchner [mailto:supercroc1974@xxxxxxxxx] > Sent: Tuesday, January 20, 2004 5:36 AM > To: gcc-help@xxxxxxxxxxx > Subject: Mysterious gethostbyname problem > > > Hi, > > I have made this program, but I can't figure out what > is wrong with it. Somehow it always freezes at the > gethostbyname command. > Does anyone have anyidea about what could be wrong? > I'm using gcc 3.2.2 on a RedHat 9 system. > > Thanks, > > Andre > > > int main() > { > printf( "%d\n", connectSocket( "www.hotmail.com", 80 ) > ); > return( 0 ); > } > > > int connectSocket( const char * hostName, const int > portno ) > { > int sockfd; > struct hostent *server = 0; > struct sockaddr_in serv_addr; > > // create the socket > sockfd = socket( AF_INET, SOCK_STREAM, 0 ); > if ( sockfd < 0 ) > return( -1 ); > > // determine the host > if( ( server = gethostbyname( hostName ) ) == NULL ) > { > printf( "Error number: %d\n", errno ); > return( -1 ); > } > > // connect to the host > bzero( ( char * ) &serv_addr, sizeof( serv_addr ) ); > serv_addr.sin_family = AF_INET; > bcopy( ( char * ) server -> h_addr, ( char * ) > &serv_addr.sin_addr.s_addr, server -> h_length ); > serv_addr.sin_port = htons( portno ); > if ( connect( sockfd, ( struct sockaddr* ) > &serv_addr, sizeof( serv_addr ) ) < 0 ) > return( -1 ); > > return( sockfd ); > } > > > __________________________________ > Do you Yahoo!? > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes > http://hotjobs.sweepstakes.yahoo.com/signingbonus >