Date: Tue, 31 Jul 2001 15:54:35 +0400 (MSK) From: Grigory Kljuchnikov <grn@ispras.ru> To: <freebsd-questions@FreeBSD.ORG> Subject: How can I get udp socket error status Message-ID: <Pine.GSO.4.33.0107311548400.28297-100000@gate.ispras.ru>
next in thread | raw e-mail | index | archive | help
Hello, I'm making udp echo server and client for some testing purpose. They work properly, but I don't know how application can get ICMP error (for example after sendto() - ICMP_UNREACH, if there isn't server process on remote side) for appropriate udp socket. I've tried: ---- sockfd = socket(AF_INET, SOCK_DGRAM, 0); bind(sockfd, (struct sockaddr *) &cli, sizeof(cli)); if (sendto(sockfd, sendline, n, 0, pserv_addr, servlen) != n ) { perror("sendto error"); exit(-1); } sleep(1); getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &stat, &n); ----- but 'stat' always = 0 (no error). I think sendto() doesn't wait an error and ICMP_UNREACH don't affect to the socket. In Solaris there is an option: SO_DGRAM_ERRIND application wants delayed error that makes it possible to receive errors for datagram sockets that are not connected. My question is how application can get errors from ICMP for connectionless socket after sending a packet to the server? I don't subscribe to the maillist, please reply to my mail address grn@ispras.ru! Thank you. Grigory Klyuchnikov, System Engineer, Institute for System Programming Russian Academy of Sciences To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.33.0107311548400.28297-100000>