Class: Kgio::UNIXServer
- Inherits:
-
UNIXServer
- Object
- UNIXServer
- Kgio::UNIXServer
- Defined in:
- ext/kgio/accept.c,
ext/kgio/accept.c
Overview
Kgio::UNIXServer should be used in place of the plain UNIXServer when kgio_accept and kgio_tryaccept methods are needed.
Instance Method Summary collapse
-
#kgio_accept(*args) ⇒ Object
server = Kgio::UNIXServer.new(“/path/to/unix/socket”) server.kgio_accept -> Kgio::Socket or nil server.kgio_accept(klass = MySocket) -> MySocket or nil server.kgio_accept(nil, flags) -> Kgio::Socket or nil.
-
#kgio_tryaccept(*args) ⇒ Object
server = Kgio::UNIXServer.new(“/path/to/unix/socket”) server.kgio_tryaccept -> Kgio::Socket or nil server.kgio_tryaccept(klass = MySocket) -> MySocket or nil server.kgio_tryaccept(nil, flags) -> Kgio::Socket or nil.
Instance Method Details
#kgio_accept(*args) ⇒ Object
server = Kgio::UNIXServer.new(“/path/to/unix/socket”) server.kgio_accept -> Kgio::Socket or nil server.kgio_accept(klass = MySocket) -> MySocket or nil server.kgio_accept(nil, flags) -> Kgio::Socket or nil
Initiates a blocking accept and returns a generic Kgio::Socket object with the kgio_addr attribute set (to the value of Kgio::LOCALHOST) on success.
On Ruby implementations using native threads, this can use a blocking accept(2) (or accept4(2)) system call to avoid thundering herds.
An optional klass
argument may be specified to override the Kgio::Socket-class on a successful return value.
An optional flags
argument may also be specified. flags
is a bitmask that may contain any combination of:
-
Kgio::SOCK_CLOEXEC - close-on-exec flag (enabled by default)
-
Kgio::SOCK_NONBLOCK - non-blocking flag (unimportant)
367 368 369 370 371 372 373 374 375 |
# File 'ext/kgio/accept.c', line 367
static VALUE unix_accept(int argc, VALUE *argv, VALUE self)
{
struct accept_args a;
a.addr = NULL;
a.addrlen = NULL;
prepare_accept(&a, self, argc, argv);
return my_accept(&a, 0);
}
|
#kgio_tryaccept(*args) ⇒ Object
server = Kgio::UNIXServer.new(“/path/to/unix/socket”) server.kgio_tryaccept -> Kgio::Socket or nil server.kgio_tryaccept(klass = MySocket) -> MySocket or nil server.kgio_tryaccept(nil, flags) -> Kgio::Socket or nil
Initiates a non-blocking accept and returns a generic Kgio::Socket object with the kgio_addr attribute set (to the value of Kgio::LOCALHOST) on success.
An optional klass
argument may be specified to override the Kgio::Socket-class on a successful return value.
An optional flags
argument may also be specified. flags
is a bitmask that may contain any combination of:
-
Kgio::SOCK_CLOEXEC - close-on-exec flag (enabled by default)
-
Kgio::SOCK_NONBLOCK - non-blocking flag (unimportant)
333 334 335 336 337 338 339 340 341 |
# File 'ext/kgio/accept.c', line 333
static VALUE unix_tryaccept(int argc, VALUE *argv, VALUE self)
{
struct accept_args a;
a.addr = NULL;
a.addrlen = NULL;
prepare_accept(&a, self, argc, argv);
return my_accept(&a, 1);
}
|