Si in effetti tramite la variabile errno:Originariamente inviato da and77
Non dovrebbe avvisarmi che a quell'indirizzo non c'è alcun server in ascolto?
Comunque, hai provato a rivedere la condizione dell' if? Può anche dipendere da quello.. Per esempio, io la connect l'ho sempre richiamata così:Errors
...
ECONNREFUSED
No one listening on the remote address.
...
ENETUNREACH
Network is unreachable.
...
ETIMEDOUT
Timeout while attempting connection. The server may be too busy to accept new connections. Note that for IP sockets the timeout may be very long when syncookies are enabled on the server.
Ed ha sempre funzionato, se non ricordo male, con condizioni diverse toppava..codice:if((connect( ... , (struct sockaddr *)& ... , sizeof( ... ))) != -1) printf("Ok connect\n"); else { perror ... ... }

Rispondi quotando