End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
TCPServer#accept
tcpserver.accept => tcpsocket
ext/socket/tcpserver.c
View on GitHub ↗
static VALUE
tcp_accept(VALUE sock)
{
rb_io_t *fptr;
union_sockaddr from;
socklen_t fromlen;
GetOpenFile(sock, fptr);
fromlen = (socklen_t)sizeof(from);
return rsock_s_accept(rb_cTCPSocket, fptr->fd, &from.addr, &fromlen);
}
Accepts an incoming connection. It returns a new TCPSocket object.
Example
TCPServer.open("127.0.0.1", 14641) {|serv| s = serv.accept s.puts Time.now s.close }