2014-11-05 15 views
8

Sto tentando di utilizzare SO_NOSIGPIPE in un socket tcp.SO_NOSIGPIPE non è stato rifiutato

int set = 1; 
    setsockopt(sockDesc, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int); 

ma un errore è in arrivo:

error: SO_NOSIGPIPE was not declared in this scope 

È stato rilevato qualche file header necessari, per usare questo. Ho cercato su Internet ma non ho trovato alcuna soluzione utile.

+1

possibile duplicato di [Come impedire SIGPIPE (o gestirli correttamente)] (http://stackoverflow.com/questions/108183/how-to-prevent-sigpipes-or-handle-them-properly) –

+1

Non è un'opzione standard, devi trovare un altro modo per gestire (o ignorare) il segnale. Per un elenco di tutte le opzioni standard, vedi ad es. [questo riferimento] (http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_10_16). –

+0

Forse questo ti aiuta? http://stackoverflow.com/q/17682349/2003898 – dhein

risposta

10

Non c'è SO_NOSIGPIPE in Linux (né altri sistemi). È invece possibile utilizzare il flag MSG_NOSIGNAL quando si chiama send() o utilizzare signal(SIGPIPE, SIG_IGN) per ignorare l'intera applicazione SIGPIPE.

Problemi correlati