diff options
author | Diego Nehab <diego@impa.br> | 2012-08-23 19:31:15 -0300 |
---|---|---|
committer | Diego Nehab <diego@impa.br> | 2012-08-23 19:31:15 -0300 |
commit | 6368caeb5ab5f628b8021c8ebf4d6df436162aaf (patch) | |
tree | 2a2005f2e27ee81e8ced7e4fc84098728e106af0 /src/tcp.c | |
parent | 03ba06f70c9ad5cdc9b49d816490fc28d6dbbdc5 (diff) | |
download | luasocket-6368caeb5ab5f628b8021c8ebf4d6df436162aaf.tar.gz luasocket-6368caeb5ab5f628b8021c8ebf4d6df436162aaf.tar.bz2 luasocket-6368caeb5ab5f628b8021c8ebf4d6df436162aaf.zip |
Fix udp:setpeername("*")
There seems to be a curious difference between MacOS and
Linux and I am not sure if this is documented. When you
break a "connection" on Mac OS, you only eliminate the peer
association, but the local address remains bound. On Linux,
breaking a "connection" eliminates the binding to the local
address. Have you guys ever come accross this?
Another irritating difference is that connect() returns the
error EAFNOSUPPORT on Mac OS. I am going to ignore all
errors when the reason for calling connect() is simply to
break the "connection".
Diffstat (limited to 'src/tcp.c')
-rw-r--r-- | src/tcp.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -222,6 +222,7 @@ static int meth_bind(lua_State *L) | |||
222 | bindhints.ai_socktype = SOCK_STREAM; | 222 | bindhints.ai_socktype = SOCK_STREAM; |
223 | bindhints.ai_family = tcp->family; | 223 | bindhints.ai_family = tcp->family; |
224 | bindhints.ai_flags = AI_PASSIVE; | 224 | bindhints.ai_flags = AI_PASSIVE; |
225 | address = strcmp(address, "*")? address: NULL; | ||
225 | err = inet_trybind(&tcp->sock, address, port, &bindhints); | 226 | err = inet_trybind(&tcp->sock, address, port, &bindhints); |
226 | if (err) { | 227 | if (err) { |
227 | lua_pushnil(L); | 228 | lua_pushnil(L); |
@@ -247,8 +248,7 @@ static int meth_connect(lua_State *L) | |||
247 | /* make sure we try to connect only to the same family */ | 248 | /* make sure we try to connect only to the same family */ |
248 | connecthints.ai_family = tcp->family; | 249 | connecthints.ai_family = tcp->family; |
249 | timeout_markstart(&tcp->tm); | 250 | timeout_markstart(&tcp->tm); |
250 | err = inet_tryconnect(&tcp->sock, address, port, | 251 | err = inet_tryconnect(&tcp->sock, address, port, &tcp->tm, &connecthints); |
251 | &tcp->tm, &connecthints); | ||
252 | /* have to set the class even if it failed due to non-blocking connects */ | 252 | /* have to set the class even if it failed due to non-blocking connects */ |
253 | auxiliar_setclass(L, "tcp{client}", 1); | 253 | auxiliar_setclass(L, "tcp{client}", 1); |
254 | if (err) { | 254 | if (err) { |