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);
307 #define WAIT_IN_PROGRESS 10
310 #define WAIT_IN_PROGRESS 10
314 #define WAIT_IN_PROGRESS 0
316 #ifndef WAIT_IN_PROGRESS
318 #define WAIT_IN_PROGRESS 1
334 #if defined(SOCKS) && !defined(SOCKS5)
336 socks_connect_blocking(
void *data)
349 #if WAIT_IN_PROGRESS > 0
350 int wait_in_progress = -1;
352 socklen_t sockerrlen;
358 #if defined(SOCKS) && !defined(SOCKS5)
359 if (socks) func = socks_connect_blocking;
366 #if defined(ERESTART)
375 #if WAIT_IN_PROGRESS > 0
376 sockerrlen = (socklen_t)
sizeof(sockerr);
377 status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (
void *)&sockerr, &sockerrlen);
388 #if WAIT_IN_PROGRESS > 0
398 #if WAIT_IN_PROGRESS > 0
400 if (wait_in_progress-- > 0) {
406 sockerrlen = (socklen_t)
sizeof(sockerr);
407 status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (
void *)&sockerr, &sockerrlen);
408 if (!status && !sockerr) {
409 struct timeval tv = {0, 100000};
438 flags =
fcntl(fd, F_GETFL);
455 socklen_t len0 = len ? *len : 0;
459 fd2 = accept(fptr->
fd, (
struct sockaddr*)sockaddr, len);
463 #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
474 if (len && len0 < *len) *len = len0;
492 if (arg->
len) len0 = *arg->
len;
494 if (arg->
len && len0 < *arg->
len) *arg->
len = len0;
528 if (!klass)
return INT2NUM(fd2);
536 socklen_t sslen = (socklen_t)
sizeof(ss);
539 if (getsockname(sockfd, (
struct sockaddr*)&ss, &sslen) < 0)