diff options
| author | Sam Roberts <vieuxtech@gmail.com> | 2012-04-11 14:18:20 -0700 |
|---|---|---|
| committer | Sam Roberts <vieuxtech@gmail.com> | 2012-04-11 14:18:20 -0700 |
| commit | 4b671f4551e98ac9e1d9a7407d3dffdd7eb1d3dc (patch) | |
| tree | ba92aa753ae1b145760cb1c5e69c886d3bf11328 /src/udp.c | |
| parent | f399ab25fcecad2ff96a5977e8eaf069bb45473c (diff) | |
| parent | 195b2a74bb3f368b1f31f9c8bbc1ce0f54de2035 (diff) | |
| download | luasocket-4b671f4551e98ac9e1d9a7407d3dffdd7eb1d3dc.tar.gz luasocket-4b671f4551e98ac9e1d9a7407d3dffdd7eb1d3dc.tar.bz2 luasocket-4b671f4551e98ac9e1d9a7407d3dffdd7eb1d3dc.zip | |
Merge branch 'git-sam' into diego-sam-mwild-integration
Conflicts in options.c were just due to independent small functions
being close to each other.
unix.c in mwild was broken, it wasn't using LUASOCKET_API.
serial.c needed luaL_reg renamed, and to use LUASOCKET_API.
makefile didn't respect standard DESTDIR and prefix makefile
variables, and didn't allow LUAV variable to select lua version to build
against.
I've tested the top-level install-both target builds and installs
against both lua5.1 and lua5.2, but not done further testing.
Conflicts:
README
config
gem/ltn012.tex
makefile
src/makefile
src/options.c
src/options.h
src/tcp.c
src/usocket.c
Diffstat (limited to 'src/udp.c')
| -rw-r--r-- | src/udp.c | 6 |
1 files changed, 6 insertions, 0 deletions
| @@ -184,6 +184,9 @@ static int meth_receive(lua_State *L) { | |||
| 184 | count = MIN(count, sizeof(buffer)); | 184 | count = MIN(count, sizeof(buffer)); |
| 185 | timeout_markstart(tm); | 185 | timeout_markstart(tm); |
| 186 | err = socket_recv(&udp->sock, buffer, count, &got, tm); | 186 | err = socket_recv(&udp->sock, buffer, count, &got, tm); |
| 187 | /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */ | ||
| 188 | if (err == IO_CLOSED) | ||
| 189 | err = IO_DONE; | ||
| 187 | if (err != IO_DONE) { | 190 | if (err != IO_DONE) { |
| 188 | lua_pushnil(L); | 191 | lua_pushnil(L); |
| 189 | lua_pushstring(L, udp_strerror(err)); | 192 | lua_pushstring(L, udp_strerror(err)); |
| @@ -208,6 +211,9 @@ static int meth_receivefrom(lua_State *L) { | |||
| 208 | count = MIN(count, sizeof(buffer)); | 211 | count = MIN(count, sizeof(buffer)); |
| 209 | err = socket_recvfrom(&udp->sock, buffer, count, &got, | 212 | err = socket_recvfrom(&udp->sock, buffer, count, &got, |
| 210 | (SA *) &addr, &addr_len, tm); | 213 | (SA *) &addr, &addr_len, tm); |
| 214 | /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */ | ||
| 215 | if (err == IO_CLOSED) | ||
| 216 | err = IO_DONE; | ||
| 211 | if (err == IO_DONE) { | 217 | if (err == IO_DONE) { |
| 212 | lua_pushlstring(L, buffer, got); | 218 | lua_pushlstring(L, buffer, got); |
| 213 | lua_pushstring(L, inet_ntoa(addr.sin_addr)); | 219 | lua_pushstring(L, inet_ntoa(addr.sin_addr)); |
