From: Perl 5 Porters Date: Mon, 22 Jul 1996 05:46:13 +0000 (+0000) Subject: perl 5.003_01: vms/sockadapt.c X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42084d09ce1dc5746ea524ec4acdba6f45ae3355;p=p5sagit%2Fp5-mst-13.2.git perl 5.003_01: vms/sockadapt.c Add getpeername() shim to convert successful-but-no-address result to the error expected by the Perl core. --- diff --git a/vms/sockadapt.c b/vms/sockadapt.c index 08251d6..cc130a5 100644 --- a/vms/sockadapt.c +++ b/vms/sockadapt.c @@ -41,3 +41,26 @@ void setnetent() { void endnetent() { croak("Function \"endnetent\" not implemented in this version of perl"); } + +/* Some TCP/IP implementations seem to return success, when getpeername() + * is called on a UDP socket, but the port and in_addr are all zeroes. + */ + +int my_getpeername(int sock, struct sockaddr *addr, int *addrlen) { + static char nowhere[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + int rslt; + + rslt = si_getpeername(sock, addr, addrlen); + + /* Just pass an error back up the line */ + if (rslt) return rslt; + + /* If the call succeeded, make sure we don't have a zeroed port/addr */ + if (addr->sa_family == AF_INET && + !memcmp((char *)addr + sizeof(u_short), nowhere, + sizeof(u_short) + sizeof(struct in_addr))) { + rslt = -1; + SETERRNO(ENOTCONN,SS$_CLEARED); + } + return rslt; +}