La funzione inet_aton causa un segmantation fault al client della chat che sto cercando di creare. Mi spiego meglio:
Praticamente, l'output del programma dovrebbe essere ciao1 ciao2, invece si ferma a ciao1 e premuto invio, causa il segmentation fault, senza che sia ritornato nessun errore prima. Premetto che su Ubuntu 64 bit, tale codice funziona perfettamente. L'errore compare in ubuntu 32bitcodice:#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdlib.h> #include <signal.h> #define N_PORTA 1999 #define BUFFER 1024 void handler( int sign ) ; int main(){ char buffer[BUFFER]; int sock ,pid_padre ; struct sigaction new_handler; struct sockaddr_in server_option ; char server_addr_dd [] = "127.0.0.1"; //indirizzo server formato dotted decimal system("clear"); new_handler . sa_handler = handler; /** Creazione socket */ if ( (sock = socket( PF_INET , SOCK_STREAM , 0 ) ) < 0 ) { perror ( "Socket creation error" ) ; exit ( -1 ) ; } /** Trasformazione indirizzo dotted_decimal in un indirizzo IP */ printf("ciao1"); getchar(); if ( (inet_aton ( server_addr_dd, server_option.sin_addr )) == 1 ) { perror ( "Conversione IP non riuscita" ) ; exit ( -1 ); } printf("ciao2"); getchar();![]()
Aiutatemi, l'esame si avvicina![]()

Rispondi quotando