28 VALUE rb_cSOCKSSocket;
49 if (
fstat(fd, &sbuf) < 0)
52 if (!S_ISSOCK(sbuf.st_mode))
125 arg.
alen = (socklen_t)
sizeof(arg.
buf);
128 klass =
RBASIC(str)->klass;
142 RBASIC(str)->klass = klass;
152 if (arg.
alen !=
sizeof(
struct sockaddr_in)) {
168 rb_bug(
"rsock_s_recvfrom called with bad value");
178 socklen_t alen = (socklen_t)
sizeof buf;
187 if (flg ==
Qnil) flags = 0;
194 flags |= MSG_DONTWAIT;
207 slen = recvfrom(fd,
RSTRING_PTR(str), buflen, flags, (
struct sockaddr*)&buf, &alen);
212 #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
228 if (alen && alen !=
sizeof(buf))
237 rb_bug(
"rsock_s_recvfrom_nonblock called with bad value");
247 fd = socket(domain, type, proto);
251 fd = socket(domain, type, proto);
263 socklen_t sockerrlen;
275 sockerrlen = (socklen_t)
sizeof(sockerr);
276 ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, (
void *)&sockerr, &sockerrlen);
303 #define WAIT_IN_PROGRESS 10
306 #define WAIT_IN_PROGRESS 10
310 #define WAIT_IN_PROGRESS 0
312 #ifndef WAIT_IN_PROGRESS
314 #define WAIT_IN_PROGRESS 1
330 #if defined(SOCKS) && !defined(SOCKS5)
332 socks_connect_blocking(
void *data)
345 #if WAIT_IN_PROGRESS > 0
346 int wait_in_progress = -1;
348 socklen_t sockerrlen;
354 #if defined(SOCKS) && !defined(SOCKS5)
355 if (socks) func = socks_connect_blocking;
362 #if defined(ERESTART)
371 #if WAIT_IN_PROGRESS > 0
372 sockerrlen = (socklen_t)
sizeof(sockerr);
373 status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (
void *)&sockerr, &sockerrlen);
384 #if WAIT_IN_PROGRESS > 0
394 #if WAIT_IN_PROGRESS > 0
396 if (wait_in_progress-- > 0) {
402 sockerrlen = (socklen_t)
sizeof(sockerr);
403 status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (
void *)&sockerr, &sockerrlen);
404 if (!status && !sockerr) {
405 struct timeval tv = {0, 100000};
434 flags =
fcntl(fd, F_GETFL);
451 socklen_t len0 = len ? *len : 0;
455 fd2 = accept(fptr->
fd, (
struct sockaddr*)sockaddr, len);
459 #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
470 if (len && len0 < *len) *len = len0;
488 if (arg->
len) len0 = *arg->
len;
490 if (arg->
len && len0 < *arg->
len) *arg->
len = len0;
524 if (!klass)
return INT2NUM(fd2);
532 socklen_t sslen = (socklen_t)
sizeof(ss);
535 if (getsockname(sockfd, (
struct sockaddr*)&ss, &sslen) < 0)