summaryrefslogtreecommitdiff
path: root/ext/socket/basicsocket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-10 14:31:21 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-10 14:31:21 +0000
commit6245caf58ccd2ccafc829c9c6a37b2b534c0a94d (patch)
tree48480d919e055e8417bd573e463defd0e10f9360 /ext/socket/basicsocket.c
parent1463f1dfe70005ca1eac16547097370f6b9c6466 (diff)
* ext/socket/basicsocket.c (bsock_getpeername): use struct
sockaddr_storage. (bsock_local_address): ditto. (bsock_remote_address): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/basicsocket.c')
-rw-r--r--ext/socket/basicsocket.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index 7690fb6..88f8b1b 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -351,14 +351,14 @@ bsock_getsockname(VALUE sock)
static VALUE
bsock_getpeername(VALUE sock)
{
- char buf[1024];
+ struct sockaddr_storage buf;
socklen_t len = sizeof buf;
rb_io_t *fptr;
GetOpenFile(sock, fptr);
- if (getpeername(fptr->fd, (struct sockaddr*)buf, &len) < 0)
+ if (getpeername(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
rb_sys_fail("getpeername(2)");
- return rb_str_new(buf, len);
+ return rb_str_new((char*)&buf, len);
}
/*
@@ -377,14 +377,14 @@ bsock_getpeername(VALUE sock)
static VALUE
bsock_local_address(VALUE sock)
{
- char buf[1024];
+ struct sockaddr_storage buf;
socklen_t len = sizeof buf;
rb_io_t *fptr;
GetOpenFile(sock, fptr);
- if (getsockname(fptr->fd, (struct sockaddr*)buf, &len) < 0)
+ if (getsockname(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
rb_sys_fail("getsockname(2)");
- return fd_socket_addrinfo(fptr->fd, (struct sockaddr *)buf, len);
+ return fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
}
/*
@@ -405,14 +405,14 @@ bsock_local_address(VALUE sock)
static VALUE
bsock_remote_address(VALUE sock)
{
- char buf[1024];
+ struct sockaddr_storage buf;
socklen_t len = sizeof buf;
rb_io_t *fptr;
GetOpenFile(sock, fptr);
- if (getpeername(fptr->fd, (struct sockaddr*)buf, &len) < 0)
+ if (getpeername(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
rb_sys_fail("getpeername(2)");
- return fd_socket_addrinfo(fptr->fd, (struct sockaddr *)buf, len);
+ return fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
}
/*