summaryrefslogtreecommitdiff
path: root/vms
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-07-22 05:46:13 +0000
committerCharles Bailey <bailey@genetics.upenn.edu>1996-07-22 05:46:13 +0000
commit42084d09ce1dc5746ea524ec4acdba6f45ae3355 (patch)
tree6628964cab50a66cb6650e494508cd644c7ac902 /vms
parent1c9f8daada8b588a614aea510638b830b9cad417 (diff)
downloadperl-42084d09ce1dc5746ea524ec4acdba6f45ae3355.tar.gz
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.
Diffstat (limited to 'vms')
-rw-r--r--vms/sockadapt.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/vms/sockadapt.c b/vms/sockadapt.c
index 08251d6bdf..cc130a5598 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;
+}