Feature #4906 ยป add_socket.1_9.patch
include/ruby/win32.h (working copy) | ||
---|---|---|
extern rb_pid_t rb_w32_pipe_exec(const char *, const char *, int, int *, int *);
|
||
extern int flock(int fd, int oper);
|
||
extern int rb_w32_has_cancel_io(void);
|
||
extern int rb_w32_add_socket(SOCKET, int);
|
||
extern void rb_w32_remove_socket(int);
|
||
extern int rb_w32_is_socket(int);
|
||
extern int WSAAPI rb_w32_accept(int, struct sockaddr *, int *);
|
||
extern int WSAAPI rb_w32_bind(int, const struct sockaddr *, int);
|
win32/win32.c (working copy) | ||
---|---|---|
}
|
||
#endif
|
||
int
|
||
rb_w32_add_socket(SOCKET sock, int flag)
|
||
{
|
||
int fd = rb_w32_open_osfhandle(sock, O_RDWR|O_BINARY|O_NOINHERIT);
|
||
if (fd != -1) {
|
||
st_insert(socklist, (st_data_t)sock, (st_data_t)flag);
|
||
}
|
||
return fd;
|
||
}
|
||
void
|
||
rb_w32_remove_socket(int fd)
|
||
{
|
||
SOCKET sock = TO_SOCKET(fd);
|
||
st_data_t key = (st_data_t)sock;
|
||
st_delete(socklist, &key, NULL);
|
||
_set_osfhnd(fd, (SOCKET)INVALID_HANDLE_VALUE);
|
||
_close(fd);
|
||
}
|
||
#undef getsockopt
|
||
static int
|