diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-05-25 01:56:46 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-05-25 01:56:46 +0000 |
| commit | b2724ad2d1cc3768a04270ed3f8014ec65ad133b (patch) | |
| tree | 8b9995f8668103ed69498a63ccb6fc9d654b0b25 /src | |
| parent | 0f6c8d50a99997ac7829864b1c93362b50f1bbf3 (diff) | |
| download | luasocket-b2724ad2d1cc3768a04270ed3f8014ec65ad133b.tar.gz luasocket-b2724ad2d1cc3768a04270ed3f8014ec65ad133b.tar.bz2 luasocket-b2724ad2d1cc3768a04270ed3f8014ec65ad133b.zip | |
New sock.h has nothing to do with class sock...
Diffstat (limited to 'src')
| -rw-r--r-- | src/socket.h | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/src/socket.h b/src/socket.h index 9972639..f8c5d8f 100644 --- a/src/socket.h +++ b/src/socket.h | |||
| @@ -1,24 +1,57 @@ | |||
| 1 | /*=========================================================================*\ | 1 | /*=========================================================================*\ |
| 2 | * Socket class: inherits from the File Descriptor class and is here just | 2 | * Socket compatibilization module |
| 3 | * for extensibility in the future | ||
| 4 | * | 3 | * |
| 5 | * RCS ID: $id$ | 4 | * RCS ID: $Id$ |
| 6 | \*=========================================================================*/ | 5 | \*=========================================================================*/ |
| 7 | #ifndef SOCK_H_ | 6 | #ifndef SOCK_H |
| 8 | #define SOCK_H_ | 7 | #define SOCK_H |
| 9 | 8 | ||
| 10 | #include <lua.h> | 9 | #include <lua.h> |
| 11 | #include "lsfd.h" | 10 | #include "error.h" |
| 12 | 11 | ||
| 13 | #define SOCK_CLASS "luasocket(sock)" | 12 | /*=========================================================================*\ |
| 13 | * Platform specific compatibilization | ||
| 14 | \*=========================================================================*/ | ||
| 15 | #ifdef WIN32 | ||
| 16 | #include "sockwin32.h" | ||
| 17 | #else | ||
| 18 | #include "sockunix.h" | ||
| 19 | #endif | ||
| 20 | |||
| 21 | /* we are lazy... */ | ||
| 22 | typedef struct sockaddr SA; | ||
| 23 | |||
| 24 | /*=========================================================================*\ | ||
| 25 | * Functions bellow implement a comfortable platform independent | ||
| 26 | * interface to sockets | ||
| 27 | \*=========================================================================*/ | ||
| 28 | int sock_open(lua_State *L); | ||
| 29 | |||
| 30 | const char *sock_create(p_sock ps, int domain, int type, int protocol); | ||
| 31 | void sock_destroy(p_sock ps); | ||
| 32 | void sock_accept(p_sock ps, p_sock pa, SA *addr, size_t *addr_len, int timeout); | ||
| 33 | const char *sock_connect(p_sock ps, SA *addr, size_t addr_len); | ||
| 34 | const char *sock_bind(p_sock ps, SA *addr, size_t addr_len); | ||
| 35 | void sock_listen(p_sock ps, int backlog); | ||
| 36 | |||
| 37 | int sock_send(p_sock ps, const char *data, size_t count, | ||
| 38 | size_t *sent, int timeout); | ||
| 39 | int sock_recv(p_sock ps, char *data, size_t count, | ||
| 40 | size_t *got, int timeout); | ||
| 41 | int sock_sendto(p_sock ps, const char *data, size_t count, | ||
| 42 | size_t *sent, SA *addr, size_t addr_len, int timeout); | ||
| 43 | int sock_recvfrom(p_sock ps, char *data, size_t count, | ||
| 44 | size_t *got, SA *addr, size_t *addr_len, int timeout); | ||
| 14 | 45 | ||
| 15 | #define SOCK_FIELDS FD_FIELDS | 46 | void sock_setnonblocking(p_sock ps); |
| 47 | void sock_setblocking(p_sock ps); | ||
| 48 | void sock_setreuseaddr(p_sock ps); | ||
| 16 | 49 | ||
| 17 | typedef t_fd t_sock; | 50 | const char *sock_hoststrerror(void); |
| 18 | typedef t_sock *p_sock; | 51 | const char *sock_createstrerror(void); |
| 52 | const char *sock_bindstrerror(void); | ||
| 53 | const char *sock_connectstrerror(void); | ||
| 19 | 54 | ||
| 20 | void sock_open(lua_State *L); | 55 | const char *sock_trysetoptions(lua_State *L, p_sock ps); |
| 21 | void sock_construct(lua_State *L, p_sock sock); | ||
| 22 | void sock_inherit(lua_State *L, cchar *lsclass); | ||
| 23 | 56 | ||
| 24 | #endif /* SOCK_H_ */ | 57 | #endif /* SOCK_H */ |
