summaryrefslogtreecommitdiff
path: root/win32/win32sck.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-11-21 07:49:06 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-11-21 07:49:06 +0000
commite4449fe1872a24e805fcc129361ea26a406317d8 (patch)
treee44adcbafcafecf419ec781a3c457b33e7570be7 /win32/win32sck.c
parent0372dbb61d521c83c2819b6bb21a87e9c2914f11 (diff)
downloadperl-e4449fe1872a24e805fcc129361ea26a406317d8.tar.gz
win32_recvfrom() compatibility fix
p4raw-id: //depot/perl@2254
Diffstat (limited to 'win32/win32sck.c')
-rw-r--r--win32/win32sck.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/win32/win32sck.c b/win32/win32sck.c
index 52dc128f9a..2713605840 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;
}