mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-15 21:39:51 +02:00
Seems to be working on windows.
This commit is contained in:
@ -77,7 +77,7 @@ int buf_meth_send(lua_State *L, p_buf buf) {
|
||||
int top = lua_gettop(L);
|
||||
p_tm tm = tm_markstart(buf->tm);
|
||||
int err = IO_DONE;
|
||||
size_t size, sent;
|
||||
size_t size = 0, sent = 0;
|
||||
const char *data = luaL_checklstring(L, 2, &size);
|
||||
long start = (long) luaL_optnumber(L, 3, 1);
|
||||
long end = (long) luaL_optnumber(L, 4, -1);
|
||||
|
@ -228,10 +228,12 @@ static int meth_connect(lua_State *L)
|
||||
|
||||
static int meth_connected(lua_State *L)
|
||||
{
|
||||
p_tcp tcp;
|
||||
p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1);
|
||||
int err;
|
||||
tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1);
|
||||
err = sock_connected(&tcp->sock, &tcp->tm);
|
||||
t_tm tm;
|
||||
tm_init(&tm, 0.1, -1);
|
||||
tm_markstart(&tm);
|
||||
err = sock_connected(&tcp->sock, &tm);
|
||||
if (err != IO_DONE) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, sock_strerror(err));
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
/* timeout control structure */
|
||||
typedef struct t_tm_ {
|
||||
double total; /* total number of miliseconds for operation */
|
||||
double block; /* maximum time for blocking calls */
|
||||
double total; /* total number of miliseconds for operation */
|
||||
double start; /* time of start of operation */
|
||||
} t_tm;
|
||||
typedef t_tm *p_tm;
|
||||
|
@ -129,10 +129,11 @@ int sock_connect(p_sock ps, SA *addr, socklen_t len, p_tm tm) {
|
||||
\*-------------------------------------------------------------------------*/
|
||||
int sock_connected(p_sock ps, p_tm tm) {
|
||||
int err;
|
||||
/* give windows time to find out what is up (yes, disgusting) */
|
||||
if ((err = sock_waitfd(ps, WAITFD_C, tm)) == IO_CLOSED) {
|
||||
int len = sizeof(err);
|
||||
/* give windows time to set the error (yes, disgusting) */
|
||||
Sleep(0);
|
||||
Sleep(10);
|
||||
/* find out why we failed */
|
||||
getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len);
|
||||
/* we KNOW there was an error. if 'why' is 0, we will return
|
||||
|
Reference in New Issue
Block a user