Method: UNIXServer#accept

Defined in:
unixserver.c

#acceptObject

Accepts an incoming connection. It returns a new UNIXSocket object.

UNIXServer.open("/tmp/sock") {|serv|
  UNIXSocket.open("/tmp/sock") {|c|
    s = serv.accept
    s.puts "hi"
    s.close
    p c.read #=> "hi\n"
  }
}

49
50
51
52
53
54
55
56
# File 'unixserver.c', line 49

static VALUE
unix_accept(VALUE server)
{
    struct sockaddr_un buffer;
    socklen_t length = sizeof(buffer);

    return rsock_s_accept(rb_cUNIXSocket, server, (struct sockaddr*)&buffer, &length);
}