select
socket :: SocketObserver :: defaultinit
socket :: SocketObserver :: except_set
Set of file descriptors on which to watch exception eventssocket :: SocketObserver :: except_set=
Set of file descriptors on which to watch exception eventssocket :: SocketObserver :: read_set
Set of file descriptors on which to watch read eventssocket :: SocketObserver :: read_set=
Set of file descriptors on which to watch read eventssocket :: SocketObserver :: write_set
Set of file descriptors on which to watch write eventssocket :: SocketObserver :: write_set=
Set of file descriptors on which to watch write eventssocket $ SocketObserver :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
socket :: SocketObserver :: defaultinit
socket :: SocketObserver :: except_set
Set of file descriptors on which to watch exception eventssocket :: SocketObserver :: except_set=
Set of file descriptors on which to watch exception eventscore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).socket :: SocketObserver :: read_set
Set of file descriptors on which to watch read eventssocket :: SocketObserver :: read_set=
Set of file descriptors on which to watch read eventssocket :: SocketObserver :: write_set
Set of file descriptors on which to watch write eventssocket :: SocketObserver :: write_set=
Set of file descriptors on which to watch write events
# Service class to manage calls to `select`
class SocketObserver
private var native = new NativeSocketObserver
# Set of file descriptors on which to watch read events
var read_set: nullable SocketSet = null
# Set of file descriptors on which to watch write events
var write_set: nullable SocketSet = null
# Set of file descriptors on which to watch exception events
var except_set: nullable SocketSet = null
# Initialize a socket observer
init with_sets(read: Bool, write: Bool, except: Bool) do
if read then read_set = new SocketSet
if write then write_set = new SocketSet
if except then except_set = new SocketSet
end
# Watch for changes in the states of several sockets.
fun select(max: Socket, seconds: Int, microseconds: Int): Bool
do
# FIXME this implementation (see the call to nullable attributes below) and
# `NativeSockectObserver::select` is not stable.
var timeval = new NativeTimeval(seconds, microseconds)
var rd = if read_set != null then read_set.as(not null).native else null
var wrt = if write_set != null then write_set.as(not null).native else null
var expt = if except_set != null then except_set.as(not null).native else null
return native.select(max.native, rd, wrt, expt, timeval) > 0
end
end
lib/socket/socket.nit:309,1--341,3