From: Gurusamy Sarathy Date: Sat, 21 Nov 1998 07:49:06 +0000 (+0000) Subject: win32_recvfrom() compatibility fix X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4449fe1872a24e805fcc129361ea26a406317d8;p=p5sagit%2Fp5-mst-13.2.git win32_recvfrom() compatibility fix p4raw-id: //depot/perl@2254 --- diff --git a/win32/win32sck.c b/win32/win32sck.c index 52dc128..2713605 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -287,8 +287,15 @@ int win32_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen) { int r; + int frombufsize = *fromlen; SOCKET_TEST_ERROR(r = recvfrom(TO_SOCKET(s), buf, len, flags, from, fromlen)); + /* Winsock's recvfrom() only returns a valid 'from' when the socket + * is connectionless. Perl expects a valid 'from' for all types + * of sockets, so go the extra mile. + */ + if (r != SOCKET_ERROR && frombufsize == *fromlen) + (void)win32_getpeername(s, from, fromlen); return r; }