Tu hai questo prototipo, e poi nel codice scrivi:codice:void addr_initialize ( );
Passandogli tre parametri che non hai dichiarato,come fà ad andarti?codice:addr_initialize ( &server_addr , PORT , ( long ) inet_addr ( argv [ 1 ] ) );
Devi rivedere meglio il codice..
Comunque se ti serve un client di esmpio prova questo che funziona:
codice:#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include <stdlib.h> #define MAXB 8000 int main ( void ) { int sd; struct sockaddr_in client; struct hostent * hp; unsigned short port = 25; /* Simple Mail Transfer Protocol */ char buff [ MAXB ]; hp = gethostbyname( "smtp.tin.it" ); bzero ( & client , sizeof ( client ) ); client.sin_family = AF_INET; client.sin_port = htons ( port ); client.sin_addr.s_addr = ( ( struct in_addr * ) ( hp -> h_addr ) ) -> s_addr; if ( ( sd = socket ( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) fprintf ( stdout , "Errore nella creazione del socket\n" ); else fprintf ( stdout , "Socket creato!\n" ); if ( connect ( sd , ( struct sockaddr * ) & client , sizeof ( client ) ) < 0 ) fprintf ( stdout , "Errore nella connessione!\n" ); send ( sd, "Helo tin.it" , strlen ( "HELO tin.it" ) + 1 , 0 ); recv ( sd , buff , sizeof ( buff ) , 0 ); fprintf( stdout , "Risposta: %s\n" , buff ); close ( sd ); return ( 0 ); }

Rispondi quotando