|
1 #ifndef SOCKET_H |
|
2 #define SOCKET_H |
|
3 /*=========================================================================*\ |
|
4 * LuaSocket 2.0.2 |
|
5 * Copyright (C) 2004-2007 Diego Nehab |
|
6 * |
|
7 * Socket compatibilization module |
|
8 * |
|
9 * BSD Sockets and WinSock are similar, but there are a few irritating |
|
10 * differences. Also, not all *nix platforms behave the same. This module |
|
11 * (and the associated usocket.h and wsocket.h) factor these differences and |
|
12 * creates a interface compatible with the io.h module. |
|
13 * |
|
14 * RCS ID: $Id: socket.h 2 2006-04-30 19:30:47Z brunoos $ |
|
15 \*=========================================================================*/ |
|
16 #include "io.h" |
|
17 |
|
18 /*=========================================================================*\ |
|
19 * Platform specific compatibilization |
|
20 \*=========================================================================*/ |
|
21 #ifdef _WIN32 |
|
22 #include "wsocket.h" |
|
23 #else |
|
24 #include "usocket.h" |
|
25 #endif |
|
26 |
|
27 /*=========================================================================*\ |
|
28 * The connect and accept functions accept a timeout and their |
|
29 * implementations are somewhat complicated. We chose to move |
|
30 * the timeout control into this module for these functions in |
|
31 * order to simplify the modules that use them. |
|
32 \*=========================================================================*/ |
|
33 #include "timeout.h" |
|
34 |
|
35 /*=========================================================================*\ |
|
36 * Functions bellow implement a comfortable platform independent |
|
37 * interface to sockets |
|
38 \*=========================================================================*/ |
|
39 int socket_open(void); |
|
40 int socket_close(void); |
|
41 void socket_destroy(p_socket ps); |
|
42 void socket_setnonblocking(p_socket ps); |
|
43 void socket_setblocking(p_socket ps); |
|
44 int socket_waitfd(p_socket ps, int sw, p_timeout tm); |
|
45 const char *socket_strerror(int err); |
|
46 int socket_error(); |
|
47 |
|
48 #endif /* SOCKET_H */ |