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

revert sock_sysaccept addition to [ruby-dev:28861].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2006-06-26 15:09:45 +00:00
parent 61f3ff8d78
commit 429cb7c025
2 changed files with 21 additions and 4 deletions

View file

@ -2931,15 +2931,18 @@ sock_accept_nonblock(sock)
* * Socket#accept
*/
static VALUE
sock_sysaccept(VALUE sock)
sock_sysaccept(sock)
VALUE sock;
{
OpenFile *fptr;
VALUE sock2;
char buf[1024];
socklen_t len = sizeof buf;
GetOpenFile(sock, fptr);
return rb_assoc_new(s_accept(0,fptr->fd,(struct sockaddr*)buf,&len),
rb_str_new(buf, len));
sock2 = s_accept(0,fptr->fd,(struct sockaddr*)buf,&len);
return rb_assoc_new(sock2, rb_str_new(buf, len));
}
#ifdef HAVE_GETHOSTNAME

View file

@ -79,5 +79,19 @@ class TestSocket < Test::Unit::TestCase
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(sockaddr_in) }
sockaddr_un = Socket.sockaddr_un("/tmp/s")
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(sockaddr_un) }
end if Socket.respond_to?(:sockaddr_un)
def test_sysaccept
serv = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
serv.bind(Socket.sockaddr_in(0, "127.0.0.1"))
serv.listen 5
c = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
c.connect(serv.getsockname)
fd, peeraddr = serv.sysaccept
assert_equal(c.getsockname, peeraddr)
ensure
serv.close if serv
c.close if c
IO.for_fd(fd).close if fd
end
end if defined?(Socket) && Socket.respond_to?(:sockaddr_un)
end if defined?(Socket)