[Vm-dev] [commit][3501]
Fix for Mantis 7837 - Socket connect on a UDP socket does not do the
commits at squeakvm.org
commits at squeakvm.org
Sun Nov 15 23:53:15 UTC 2015
Revision: 3501
Author: lewis
Date: 2015-11-15 15:53:15 -0800 (Sun, 15 Nov 2015)
Log Message:
-----------
Fix for Mantis 7837 - Socket connect on a UDP socket does not do the
connect() call on Unix VM. This prevents query of a connected UDP socket
to find an address that an external system may use to connect to the
local system.
Verify fix by evaluating the following to find a local IPV4 address:
| s local |
s := Socket newUDP setPeer: (NetNameResolver addressForName: '8.8.8.8')
port: 0.l.
local := s localAddress.
s close.
local "==> #[172 16 0 10]"
Modified Paths:
--------------
branches/Cog/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c
Modified: branches/Cog/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c
===================================================================
--- branches/Cog/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c 2015-11-15 23:52:01 UTC (rev 3500)
+++ branches/Cog/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c 2015-11-15 23:53:15 UTC (rev 3501)
@@ -775,9 +775,12 @@
/* --- UDP/RAW --- */
if (SOCKET(s) >= 0)
{
+ int result;
memcpy((void *)&SOCKETPEER(s), (void *)&saddr, sizeof(saddr));
SOCKETPEERSIZE(s)= sizeof(struct sockaddr_in);
- SOCKETSTATE(s)= Connected;
+ result= connect(SOCKET(s), (struct sockaddr *)&saddr, sizeof(saddr));
+ if (result == 0)
+ SOCKETSTATE(s)= Connected;
}
}
else
@@ -2105,9 +2108,12 @@
{
if (SOCKET(s) >= 0)
{
+ int result;
memcpy((void *)&SOCKETPEER(s), socketAddress(addr), addressSize(addr));
SOCKETPEERSIZE(s)= addressSize(addr);
- SOCKETSTATE(s)= Connected;
+ result= connect(SOCKET(s), socketAddress(addr), addressSize(addr));
+ if (result == 0)
+ SOCKETSTATE(s)= Connected;
}
}
else /* --- TCP --- */
More information about the Vm-dev
mailing list