diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-28 21:08:50 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-28 21:08:50 +0000 |
| commit | f18d1b7cd0ec4708518ab5e18ea33b6eadca0301 (patch) | |
| tree | e831c6b1957af47db1301675b52c0d2a2e315fa7 /src/inet.c | |
| parent | 307603b24dde69eac62d2cb52123488137520c9c (diff) | |
| download | luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.tar.gz luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.tar.bz2 luasocket-f18d1b7cd0ec4708518ab5e18ea33b6eadca0301.zip | |
Closer to release...
Diffstat (limited to 'src/inet.c')
| -rw-r--r-- | src/inet.c | 9 |
1 files changed, 6 insertions, 3 deletions
| @@ -1,11 +1,14 @@ | |||
| 1 | /*=========================================================================*\ | 1 | /*=========================================================================*\ |
| 2 | * Internet domain class | 2 | * Internet domain class: inherits from the Socket class, and implement |
| 3 | * a few methods shared by all internet related objects | ||
| 3 | * Lua methods: | 4 | * Lua methods: |
| 4 | * getpeername: gets socket peer ip address and port | 5 | * getpeername: gets socket peer ip address and port |
| 5 | * getsockname: gets local socket ip address and port | 6 | * getsockname: gets local socket ip address and port |
| 6 | * Global Lua fuctions: | 7 | * Global Lua fuctions: |
| 7 | * toip: gets resolver info on host name | 8 | * toip: gets resolver info on host name |
| 8 | * tohostname: gets resolver info on dotted-quad | 9 | * tohostname: gets resolver info on dotted-quad |
| 10 | * | ||
| 11 | * RCS ID: $Id$ | ||
| 9 | \*=========================================================================*/ | 12 | \*=========================================================================*/ |
| 10 | #include <string.h> | 13 | #include <string.h> |
| 11 | 14 | ||
| @@ -145,7 +148,7 @@ static int inet_lua_getpeername(lua_State *L) | |||
| 145 | { | 148 | { |
| 146 | p_sock sock = (p_sock) lua_touserdata(L, 1); | 149 | p_sock sock = (p_sock) lua_touserdata(L, 1); |
| 147 | struct sockaddr_in peer; | 150 | struct sockaddr_in peer; |
| 148 | int peer_len = sizeof(peer); | 151 | size_t peer_len = sizeof(peer); |
| 149 | if (getpeername(sock->fd, (SA *) &peer, &peer_len) < 0) { | 152 | if (getpeername(sock->fd, (SA *) &peer, &peer_len) < 0) { |
| 150 | lua_pushnil(L); | 153 | lua_pushnil(L); |
| 151 | return 1; | 154 | return 1; |
| @@ -167,7 +170,7 @@ static int inet_lua_getsockname(lua_State *L) | |||
| 167 | { | 170 | { |
| 168 | p_sock sock = (p_sock) lua_touserdata(L, 1); | 171 | p_sock sock = (p_sock) lua_touserdata(L, 1); |
| 169 | struct sockaddr_in local; | 172 | struct sockaddr_in local; |
| 170 | int local_len = sizeof(local); | 173 | size_t local_len = sizeof(local); |
| 171 | if (getsockname(sock->fd, (SA *) &local, &local_len) < 0) { | 174 | if (getsockname(sock->fd, (SA *) &local, &local_len) < 0) { |
| 172 | lua_pushnil(L); | 175 | lua_pushnil(L); |
| 173 | return 1; | 176 | return 1; |
