1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2009-02-10 14:31:21 +00:00
parent 1463f1dfe7
commit 6245caf58c
2 changed files with 16 additions and 9 deletions

View file

@ -1,3 +1,10 @@
Tue Feb 10 23:30:32 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/basicsocket.c (bsock_getpeername): use struct
sockaddr_storage.
(bsock_local_address): ditto.
(bsock_remote_address): ditto.
Tue Feb 10 21:26:33 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/lib/socket.rb (Socket.udp_server_sockets): new method.

View file

@ -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);
}
/*