summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 1c499d9f080..63586fc0023 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -253,7 +253,7 @@ sock_connect(VALUE sock, VALUE addr)
addr = rb_str_new4(addr);
GetOpenFile(sock, fptr);
fd = fptr->fd;
- n = rsock_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr), 0);
+ n = rsock_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LENINT(addr), 0);
if (n < 0) {
rb_sys_fail("connect(2)");
}
@@ -313,7 +313,7 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
addr = rb_str_new4(addr);
GetOpenFile(sock, fptr);
rb_io_set_nonblock(fptr);
- n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr));
+ n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LENINT(addr));
if (n < 0) {
if (errno == EINPROGRESS)
rb_mod_sys_fail(rb_mWaitWritable, "connect(2) would block");
@@ -416,7 +416,7 @@ sock_bind(VALUE sock, VALUE addr)
SockAddrStringValue(addr);
GetOpenFile(sock, fptr);
- if (bind(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr)) < 0)
+ if (bind(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LENINT(addr)) < 0)
rb_sys_fail("bind(2)");
return INT2FIX(0);
@@ -706,7 +706,7 @@ sock_accept(VALUE sock)
rb_io_t *fptr;
VALUE sock2;
struct sockaddr_storage buf;
- socklen_t len = sizeof buf;
+ socklen_t len = (socklen_t)sizeof buf;
GetOpenFile(sock, fptr);
sock2 = rsock_s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)&buf,&len);
@@ -771,7 +771,7 @@ sock_accept_nonblock(VALUE sock)
rb_io_t *fptr;
VALUE sock2;
struct sockaddr_storage buf;
- socklen_t len = sizeof buf;
+ socklen_t len = (socklen_t)sizeof buf;
GetOpenFile(sock, fptr);
sock2 = rsock_s_accept_nonblock(rb_cSocket, fptr, (struct sockaddr *)&buf, &len);
@@ -822,7 +822,7 @@ sock_sysaccept(VALUE sock)
rb_io_t *fptr;
VALUE sock2;
struct sockaddr_storage buf;
- socklen_t len = sizeof buf;
+ socklen_t len = (socklen_t)sizeof buf;
GetOpenFile(sock, fptr);
sock2 = rsock_s_accept(0,fptr->fd,(struct sockaddr*)&buf,&len);
@@ -967,7 +967,7 @@ sock_s_gethostbyaddr(int argc, VALUE *argv)
t = AF_INET6;
}
#endif
- h = gethostbyaddr(RSTRING_PTR(addr), RSTRING_LEN(addr), t);
+ h = gethostbyaddr(RSTRING_PTR(addr), RSTRING_LENINT(addr), t);
if (h == NULL) {
#ifdef HAVE_HSTRERROR
extern int h_errno;
@@ -1015,7 +1015,7 @@ sock_s_getservbyname(int argc, VALUE *argv)
{
VALUE service, proto;
struct servent *sp;
- int port;
+ long port;
const char *servicename, *protoname = "tcp";
rb_scan_args(argc, argv, "11", &service, &proto);
@@ -1418,7 +1418,7 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d",
RSTRING_LEN(addr), (int)sizeof(struct sockaddr_un));
}
- sun_path = rsock_unixpath(sockaddr, RSTRING_LEN(addr));
+ sun_path = rsock_unixpath(sockaddr, RSTRING_LENINT(addr));
if (sizeof(struct sockaddr_un) == RSTRING_LEN(addr) &&
sun_path == sockaddr->sun_path &&
sun_path + strlen(sun_path) == RSTRING_PTR(addr) + RSTRING_LEN(addr)) {
@@ -1434,7 +1434,7 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
static VALUE
sockaddr_obj(struct sockaddr *addr)
{
- size_t len;
+ socklen_t len;
#if defined(AF_INET6) && defined(__KAME__)
struct sockaddr_in6 addr6;
#endif
@@ -1444,12 +1444,12 @@ sockaddr_obj(struct sockaddr *addr)
switch (addr->sa_family) {
case AF_INET:
- len = sizeof(struct sockaddr_in);
+ len = (socklen_t)sizeof(struct sockaddr_in);
break;
#ifdef AF_INET6
case AF_INET6:
- len = sizeof(struct sockaddr_in6);
+ len = (socklen_t)sizeof(struct sockaddr_in6);
# ifdef __KAME__
/* KAME uses the 2nd 16bit word of link local IPv6 address as interface index internally */
/* http://orange.kame.net/dev/cvsweb.cgi/kame/IMPLEMENTATION */
@@ -1469,17 +1469,17 @@ sockaddr_obj(struct sockaddr *addr)
#ifdef HAVE_SYS_UN_H
case AF_UNIX:
- len = sizeof(struct sockaddr_un);
+ len = (socklen_t)sizeof(struct sockaddr_un);
break;
#endif
default:
- len = sizeof(struct sockaddr_in);
+ len = (socklen_t)sizeof(struct sockaddr_in);
break;
}
#ifdef SA_LEN
if (len < (socklen_t)SA_LEN(addr))
- len = SA_LEN(addr);
+ len = (socklen_t)SA_LEN(addr);
#endif
return rsock_addrinfo_new(addr, len, addr->sa_family, 0, 0, Qnil, Qnil);