mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 22:24:28 +02:00
Compare commits
4 Commits
master
...
c4b6a62931
Author | SHA1 | Date | |
---|---|---|---|
c4b6a62931 | |||
aae30a8a7e | |||
815d6d7f3d | |||
26fd89be84 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -25,10 +25,8 @@ jobs:
|
||||
uses: luarocks/gh-actions-lua@v10
|
||||
with:
|
||||
luaVersion: ${{ matrix.luaVersion }}
|
||||
buildCache: false
|
||||
- name: Setup ‘luarocks’
|
||||
# master branch until tagged release has luajit & msvcrt fixes
|
||||
uses: luarocks/gh-actions-luarocks@master
|
||||
uses: luarocks/gh-actions-luarocks@v5
|
||||
- name: Make and install
|
||||
run: |
|
||||
luarocks make -- luasocket-scm-3.rockspec
|
||||
|
@ -37,30 +37,70 @@ Installation">
|
||||
|
||||
<!-- installation ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
<h2>Installation via luarocks</h2>
|
||||
<h2>Installation</h2>
|
||||
|
||||
<p> Here we describe the standard distribution. If the
|
||||
standard doesn't meet your needs, we refer you to the Lua
|
||||
discussion list, where any question about the package scheme
|
||||
will likely already have been answered. </p>
|
||||
|
||||
<h3>Directory structure</h3>
|
||||
|
||||
<p>LuaSocket can be easily installed using <a href="https://luarocks.org/" target="_blank">LuaRocks</a>, the Lua package manager.</p>
|
||||
<p> On Unix systems, the standard distribution uses two base
|
||||
directories, one for system dependent files, and another for system
|
||||
independent files. Let's call these directories <tt><CDIR></tt>
|
||||
and <tt><LDIR></tt>, respectively.
|
||||
For example, in my laptp, Lua 5.1 is configured to
|
||||
use '<tt>/usr/local/lib/lua/5.1</tt>' for
|
||||
<tt><CDIR></tt> and '<tt>/usr/local/share/lua/5.1</tt>' for
|
||||
<tt><LDIR></tt>. On Windows, <tt><CDIR></tt>
|
||||
usually points to the directory where the Lua executable is
|
||||
found, and <tt><LDIR></tt> points to a
|
||||
<tt>lua/</tt> directory inside <tt><CDIR></tt>. (These
|
||||
settings can be overridden by environment variables
|
||||
<tt>LUA_PATH</tt> and <tt>LUA_CPATH</tt>. See the Lua
|
||||
documentation for details.) Here is the standard LuaSocket
|
||||
distribution directory structure:</p>
|
||||
|
||||
<h3>Installing via LuaRocks</h3>
|
||||
|
||||
<p>Run the following command in your terminal:</p>
|
||||
<pre class=example>
|
||||
luarocks install luasocket
|
||||
<LDIR>/ltn12.lua
|
||||
<LDIR>/socket.lua
|
||||
<CDIR>/socket/core.dll
|
||||
<LDIR>/socket/http.lua
|
||||
<LDIR>/socket/tp.lua
|
||||
<LDIR>/socket/ftp.lua
|
||||
<LDIR>/socket/smtp.lua
|
||||
<LDIR>/socket/url.lua
|
||||
<LDIR>/mime.lua
|
||||
<CDIR>/mime/core.dll
|
||||
</pre>
|
||||
|
||||
<h3>Verification</h3>
|
||||
<p>To verify that LuaSocket is installed correctly, open Lua and run:</p>
|
||||
<pre class=example><code>
|
||||
local socket = require("socket")
|
||||
print(socket._VERSION)
|
||||
</code></pre>
|
||||
<p> Naturally, on Unix systems, <tt>core.dll</tt>
|
||||
would be replaced by <tt>core.so</tt>.
|
||||
</p>
|
||||
|
||||
<p>If you see output like <strong>LuaSocket 3.0</strong>, the installation was successful.</p>
|
||||
<h3>Using LuaSocket</h3>
|
||||
|
||||
<h3>More Information</h3>
|
||||
<p>For more details, visit the <a href="https://github.com/lunarmodules/luasocket" target="_blank">LuaSocket GitHub repository</a>.</p>
|
||||
<p> With the above setup, and an interpreter with shared library support,
|
||||
it should be easy to use LuaSocket. Just fire the interpreter and use the
|
||||
<tt>require</tt> function to gain access to whatever module you need:</p>
|
||||
|
||||
<pre class=example>
|
||||
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
||||
> socket = require("socket")
|
||||
> print(socket._VERSION)
|
||||
--> LuaSocket 3.1.0
|
||||
</pre>
|
||||
|
||||
<p> Each module loads their dependencies automatically, so you only need to
|
||||
load the modules you directly depend upon: </p>
|
||||
|
||||
<pre class=example>
|
||||
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
||||
> http = require("socket.http")
|
||||
> print(http.request("http://www.impa.br/~diego/software/luasocket"))
|
||||
--> homepage gets dumped to terminal
|
||||
</pre>
|
||||
|
||||
<!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
|
2
makefile
2
makefile
@ -10,7 +10,7 @@
|
||||
# print print the build settings
|
||||
|
||||
PLAT?= linux
|
||||
PLATS= macosx linux win32 win64 mingw freebsd solaris ucrt64
|
||||
PLATS= macosx linux win32 win64 mingw freebsd solaris
|
||||
|
||||
all: $(PLAT)
|
||||
|
||||
|
15
src/buffer.h
15
src/buffer.h
@ -18,6 +18,7 @@
|
||||
#include "luasocket.h"
|
||||
#include "io.h"
|
||||
#include "timeout.h"
|
||||
#include "common.h"
|
||||
|
||||
/* buffer size in bytes */
|
||||
#define BUF_SIZE 8192
|
||||
@ -37,13 +38,13 @@ typedef t_buffer *p_buffer;
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
int buffer_open(lua_State *L);
|
||||
void buffer_init(p_buffer buf, p_io io, p_timeout tm);
|
||||
int buffer_meth_getstats(lua_State *L, p_buffer buf);
|
||||
int buffer_meth_setstats(lua_State *L, p_buffer buf);
|
||||
int buffer_meth_send(lua_State *L, p_buffer buf);
|
||||
int buffer_meth_receive(lua_State *L, p_buffer buf);
|
||||
int buffer_isempty(p_buffer buf);
|
||||
LUASOCKET_API int buffer_open(lua_State *L);
|
||||
LUASOCKET_API void buffer_init(p_buffer buf, p_io io, p_timeout tm);
|
||||
LUASOCKET_API int buffer_meth_getstats(lua_State *L, p_buffer buf);
|
||||
LUASOCKET_API int buffer_meth_setstats(lua_State *L, p_buffer buf);
|
||||
LUASOCKET_API int buffer_meth_send(lua_State *L, p_buffer buf);
|
||||
LUASOCKET_API int buffer_meth_receive(lua_State *L, p_buffer buf);
|
||||
LUASOCKET_API int buffer_isempty(p_buffer buf);
|
||||
|
||||
#ifndef _WIN32
|
||||
#pragma GCC visibility pop
|
||||
|
16
src/common.h
Normal file
16
src/common.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef LUASOCKET_COMMON_H
|
||||
#define LUASOCKET_COMMON_H
|
||||
|
||||
#ifndef LUASOCKET_API
|
||||
#define LUASOCKET_API extern
|
||||
#endif
|
||||
|
||||
#ifndef UNIX_API
|
||||
#define UNIX_API extern
|
||||
#endif
|
||||
|
||||
#ifndef MIME_API
|
||||
#define MIME_API extern
|
||||
#endif
|
||||
|
||||
#endif
|
7
src/io.h
7
src/io.h
@ -14,13 +14,14 @@
|
||||
\*=========================================================================*/
|
||||
#include "luasocket.h"
|
||||
#include "timeout.h"
|
||||
#include "common.h"
|
||||
|
||||
/* IO error codes */
|
||||
enum {
|
||||
IO_DONE = 0, /* operation completed successfully */
|
||||
IO_TIMEOUT = -1, /* operation timed out */
|
||||
IO_CLOSED = -2, /* the connection has been closed */
|
||||
IO_UNKNOWN = -3
|
||||
IO_UNKNOWN = -3
|
||||
};
|
||||
|
||||
/* interface to error message function */
|
||||
@ -60,8 +61,8 @@ typedef t_io *p_io;
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx);
|
||||
const char *io_strerror(int err);
|
||||
LUASOCKET_API void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx);
|
||||
LUASOCKET_API const char *io_strerror(int err);
|
||||
|
||||
#ifndef _WIN32
|
||||
#pragma GCC visibility pop
|
||||
|
49
src/makefile
49
src/makefile
@ -74,13 +74,6 @@ LUAPREFIX_mingw?=/usr
|
||||
CDIR_mingw?=lua/$(LUAV)
|
||||
LDIR_mingw?=lua/$(LUAV)/lua
|
||||
|
||||
# where lua headers are found for ucrt64 builds
|
||||
# LUAINC_ucrt64:
|
||||
LUAINC_ucrt64?=/ucrt64/include
|
||||
LUALIB_ucrt64?=/ucrt64/bin/lua$(subst .,,$(LUAV)).dll
|
||||
LUAPREFIX_ucrt64?=/ucrt64
|
||||
CDIR_ucrt64?=lib/lua/$(LUAV)
|
||||
LDIR_ucrt64?=share/lua/$(LUAV)
|
||||
|
||||
# LUAINC_win32:
|
||||
# LUALIB_win32:
|
||||
@ -160,7 +153,7 @@ print:
|
||||
#------
|
||||
# Supported platforms
|
||||
#
|
||||
PLATS= macosx linux win32 win64 mingw solaris ucrt64
|
||||
PLATS= macosx linux win32 win64 mingw solaris
|
||||
|
||||
#------
|
||||
# Compiler and linker settings
|
||||
@ -169,7 +162,7 @@ SO_macosx=so
|
||||
O_macosx=o
|
||||
CC_macosx=gcc
|
||||
DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN
|
||||
CFLAGS_macosx=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common
|
||||
CFLAGS_macosx=$(LUAINC:%=-I%) $(DEF) -Wall -fno-common
|
||||
LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o
|
||||
LD_macosx=gcc
|
||||
SOCKET_macosx=usocket.o
|
||||
@ -181,8 +174,7 @@ SO_linux=so
|
||||
O_linux=o
|
||||
CC_linux=gcc
|
||||
DEF_linux=-DLUASOCKET_$(DEBUG)
|
||||
CFLAGS_linux=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \
|
||||
-Wimplicit -O2 -ggdb3 -fpic
|
||||
CFLAGS_linux=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra -Wimplicit -fpic
|
||||
LDFLAGS_linux=-O -shared -fpic -o
|
||||
LD_linux=gcc
|
||||
SOCKET_linux=usocket.o
|
||||
@ -194,9 +186,7 @@ SO_freebsd=so
|
||||
O_freebsd=o
|
||||
CC_freebsd=gcc
|
||||
DEF_freebsd=-DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN
|
||||
CFLAGS_freebsd=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \
|
||||
-Wimplicit -O2 -ggdb3 -fpic
|
||||
LDFLAGS_freebsd=-O -shared -fpic -o
|
||||
CFLAGS_freebsd=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra -Wimplicit -fpic
|
||||
LD_freebsd=gcc
|
||||
SOCKET_freebsd=usocket.o
|
||||
|
||||
@ -207,8 +197,7 @@ SO_solaris=so
|
||||
O_solaris=o
|
||||
CC_solaris=gcc
|
||||
DEF_solaris=-DLUASOCKET_$(DEBUG)
|
||||
CFLAGS_solaris=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \
|
||||
-Wimplicit -O2 -ggdb3 -fpic
|
||||
CFLAGS_solaris=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra -Wimplicit -fpic
|
||||
LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o
|
||||
LD_solaris=gcc
|
||||
SOCKET_solaris=usocket.o
|
||||
@ -221,26 +210,11 @@ O_mingw=o
|
||||
CC_mingw=gcc
|
||||
DEF_mingw= -DLUASOCKET_$(DEBUG) \
|
||||
-DWINVER=0x0501
|
||||
CFLAGS_mingw=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common
|
||||
CFLAGS_mingw=$(LUAINC:%=-I%) $(DEF) -Wall -fno-common
|
||||
LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o
|
||||
LD_mingw=gcc
|
||||
SOCKET_mingw=wsocket.o
|
||||
|
||||
#------
|
||||
# Compiler and linker settings
|
||||
# for ucrt64
|
||||
SO_ucrt64=dll
|
||||
O_ucrt64=o
|
||||
CC_ucrt64=gcc
|
||||
DEF_ucrt64= -DLUASOCKET_$(DEBUG) \
|
||||
-DWINVER=0x0501
|
||||
CFLAGS_ucrt64= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common
|
||||
# \
|
||||
-fvisibility=hidden
|
||||
LDFLAGS_ucrt64= $(LUALIB) -shared -Wl,-s -lws2_32 -o
|
||||
LD_ucrt64=gcc
|
||||
SOCKET_ucrt64=wsocket.o
|
||||
|
||||
|
||||
#------
|
||||
# Compiler and linker settings
|
||||
@ -406,9 +380,6 @@ linux:
|
||||
mingw:
|
||||
$(MAKE) all PLAT=mingw
|
||||
|
||||
ucrt64:
|
||||
$(MAKE) all PLAT=ucrt64
|
||||
|
||||
solaris:
|
||||
$(MAKE) all-unix PLAT=solaris
|
||||
|
||||
@ -421,18 +392,18 @@ none:
|
||||
all: $(SOCKET_SO) $(MIME_SO)
|
||||
|
||||
$(SOCKET_SO): $(SOCKET_OBJS)
|
||||
$(LD) $(SOCKET_OBJS) $(LDFLAGS)$@
|
||||
$(LD) $(SOCKET_OBJS) -Wl,-soname,socket/core.so $(LDFLAGS)$@
|
||||
|
||||
$(MIME_SO): $(MIME_OBJS)
|
||||
$(LD) $(MIME_OBJS) $(LDFLAGS)$@
|
||||
$(LD) $(MIME_OBJS) -Wl,-soname,mime/core.so $(LDFLAGS)$@
|
||||
|
||||
all-unix: all $(UNIX_SO) $(SERIAL_SO)
|
||||
|
||||
$(UNIX_SO): $(UNIX_OBJS)
|
||||
$(LD) $(UNIX_OBJS) $(LDFLAGS)$@
|
||||
$(LD) $(UNIX_OBJS) -Wl,-soname,socket/unix.so $(LDFLAGS)$@
|
||||
|
||||
$(SERIAL_SO): $(SERIAL_OBJS)
|
||||
$(LD) $(SERIAL_OBJS) $(LDFLAGS)$@
|
||||
$(LD) $(SERIAL_OBJS) -Wl,-soname,socket/serial.so $(LDFLAGS)$@
|
||||
|
||||
install:
|
||||
$(INSTALL_DIR) $(INSTALL_TOP_LDIR)
|
||||
|
51
src/socket.h
51
src/socket.h
@ -10,6 +10,7 @@
|
||||
* creates a interface compatible with the io.h module.
|
||||
\*=========================================================================*/
|
||||
#include "io.h"
|
||||
#include "common.h"
|
||||
|
||||
/*=========================================================================*\
|
||||
* Platform specific compatibilization
|
||||
@ -42,31 +43,31 @@ typedef struct sockaddr SA;
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
int socket_waitfd(p_socket ps, int sw, p_timeout tm);
|
||||
int socket_open(void);
|
||||
int socket_close(void);
|
||||
void socket_destroy(p_socket ps);
|
||||
int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm);
|
||||
int socket_create(p_socket ps, int domain, int type, int protocol);
|
||||
int socket_bind(p_socket ps, SA *addr, socklen_t addr_len);
|
||||
int socket_listen(p_socket ps, int backlog);
|
||||
void socket_shutdown(p_socket ps, int how);
|
||||
int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm);
|
||||
int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *addr_len, p_timeout tm);
|
||||
int socket_send(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm);
|
||||
int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, SA *addr, socklen_t addr_len, p_timeout tm);
|
||||
int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm);
|
||||
int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, SA *addr, socklen_t *addr_len, p_timeout tm);
|
||||
int socket_write(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm);
|
||||
int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm);
|
||||
void socket_setblocking(p_socket ps);
|
||||
void socket_setnonblocking(p_socket ps);
|
||||
int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp);
|
||||
int socket_gethostbyname(const char *addr, struct hostent **hp);
|
||||
const char *socket_hoststrerror(int err);
|
||||
const char *socket_strerror(int err);
|
||||
const char *socket_ioerror(p_socket ps, int err);
|
||||
const char *socket_gaistrerror(int err);
|
||||
LUASOCKET_API int socket_waitfd(p_socket ps, int sw, p_timeout tm);
|
||||
LUASOCKET_API int socket_open(void);
|
||||
LUASOCKET_API int socket_close(void);
|
||||
LUASOCKET_API void socket_destroy(p_socket ps);
|
||||
LUASOCKET_API int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm);
|
||||
LUASOCKET_API int socket_create(p_socket ps, int domain, int type, int protocol);
|
||||
LUASOCKET_API int socket_bind(p_socket ps, SA *addr, socklen_t addr_len);
|
||||
LUASOCKET_API int socket_listen(p_socket ps, int backlog);
|
||||
LUASOCKET_API void socket_shutdown(p_socket ps, int how);
|
||||
LUASOCKET_API int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm);
|
||||
LUASOCKET_API int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *addr_len, p_timeout tm);
|
||||
LUASOCKET_API int socket_send(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm);
|
||||
LUASOCKET_API int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, SA *addr, socklen_t addr_len, p_timeout tm);
|
||||
LUASOCKET_API int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm);
|
||||
LUASOCKET_API int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, SA *addr, socklen_t *addr_len, p_timeout tm);
|
||||
LUASOCKET_API int socket_write(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm);
|
||||
LUASOCKET_API int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm);
|
||||
LUASOCKET_API void socket_setblocking(p_socket ps);
|
||||
LUASOCKET_API void socket_setnonblocking(p_socket ps);
|
||||
LUASOCKET_API int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp);
|
||||
LUASOCKET_API int socket_gethostbyname(const char *addr, struct hostent **hp);
|
||||
LUASOCKET_API const char *socket_hoststrerror(int err);
|
||||
LUASOCKET_API const char *socket_strerror(int err);
|
||||
LUASOCKET_API const char *socket_ioerror(p_socket ps, int err);
|
||||
LUASOCKET_API const char *socket_gaistrerror(int err);
|
||||
|
||||
#ifndef _WIN32
|
||||
#pragma GCC visibility pop
|
||||
|
@ -5,6 +5,7 @@
|
||||
* LuaSocket toolkit
|
||||
\*=========================================================================*/
|
||||
#include "luasocket.h"
|
||||
#include "common.h"
|
||||
|
||||
/* timeout control structure */
|
||||
typedef struct t_timeout_ {
|
||||
@ -18,18 +19,18 @@ typedef t_timeout *p_timeout;
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
void timeout_init(p_timeout tm, double block, double total);
|
||||
double timeout_get(p_timeout tm);
|
||||
double timeout_getstart(p_timeout tm);
|
||||
double timeout_getretry(p_timeout tm);
|
||||
p_timeout timeout_markstart(p_timeout tm);
|
||||
LUASOCKET_API void timeout_init(p_timeout tm, double block, double total);
|
||||
LUASOCKET_API double timeout_get(p_timeout tm);
|
||||
LUASOCKET_API double timeout_getstart(p_timeout tm);
|
||||
LUASOCKET_API double timeout_getretry(p_timeout tm);
|
||||
LUASOCKET_API p_timeout timeout_markstart(p_timeout tm);
|
||||
|
||||
double timeout_gettime(void);
|
||||
LUASOCKET_API double timeout_gettime(void);
|
||||
|
||||
int timeout_open(lua_State *L);
|
||||
LUASOCKET_API int timeout_open(lua_State *L);
|
||||
|
||||
int timeout_meth_settimeout(lua_State *L, p_timeout tm);
|
||||
int timeout_meth_gettimeout(lua_State *L, p_timeout tm);
|
||||
LUASOCKET_API int timeout_meth_settimeout(lua_State *L, p_timeout tm);
|
||||
LUASOCKET_API int timeout_meth_gettimeout(lua_State *L, p_timeout tm);
|
||||
|
||||
#ifndef _WIN32
|
||||
#pragma GCC visibility pop
|
||||
|
@ -20,9 +20,6 @@
|
||||
#ifndef SOCKET_SELECT
|
||||
#include <sys/poll.h>
|
||||
|
||||
#define WAITFD_R POLLIN
|
||||
#define WAITFD_W POLLOUT
|
||||
#define WAITFD_C (POLLIN|POLLOUT)
|
||||
int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
|
||||
int ret;
|
||||
struct pollfd pfd;
|
||||
@ -41,9 +38,6 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
|
||||
}
|
||||
#else
|
||||
|
||||
#define WAITFD_R 1
|
||||
#define WAITFD_W 2
|
||||
#define WAITFD_C (WAITFD_R|WAITFD_W)
|
||||
|
||||
int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
|
||||
int ret;
|
||||
|
@ -56,4 +56,20 @@ typedef struct sockaddr_storage t_sockaddr_storage;
|
||||
|
||||
#define SOCKET_INVALID (-1)
|
||||
|
||||
#ifndef SOCKET_SELECT
|
||||
#include <sys/poll.h>
|
||||
|
||||
#define WAITFD_R POLLIN
|
||||
#define WAITFD_W POLLOUT
|
||||
#define WAITFD_C (POLLIN|POLLOUT)
|
||||
|
||||
#else
|
||||
|
||||
#define WAITFD_R 1
|
||||
#define WAITFD_W 2
|
||||
#define WAITFD_C (WAITFD_R|WAITFD_W)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* USOCKET_H */
|
||||
|
@ -42,10 +42,6 @@ int socket_close(void) {
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* Wait for readable/writable/connected socket with timeout
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#define WAITFD_R 1
|
||||
#define WAITFD_W 2
|
||||
#define WAITFD_E 4
|
||||
#define WAITFD_C (WAITFD_E|WAITFD_W)
|
||||
|
||||
int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
|
||||
int ret;
|
||||
|
@ -30,4 +30,9 @@ typedef t_socket *p_socket;
|
||||
#define AI_NUMERICSERV (0)
|
||||
#endif
|
||||
|
||||
#define WAITFD_R 1
|
||||
#define WAITFD_W 2
|
||||
#define WAITFD_E 4
|
||||
#define WAITFD_C (WAITFD_E|WAITFD_W)
|
||||
|
||||
#endif /* WSOCKET_H */
|
||||
|
Reference in New Issue
Block a user