Service class to manage calls to select

Introduced properties

fun except_set: nullable SocketSet

socket :: SocketObserver :: except_set

Set of file descriptors on which to watch exception events
protected fun except_set=(except_set: nullable SocketSet)

socket :: SocketObserver :: except_set=

Set of file descriptors on which to watch exception events
fun read_set: nullable SocketSet

socket :: SocketObserver :: read_set

Set of file descriptors on which to watch read events
protected fun read_set=(read_set: nullable SocketSet)

socket :: SocketObserver :: read_set=

Set of file descriptors on which to watch read events
fun select(max: Socket, seconds: Int, microseconds: Int): Bool

socket :: SocketObserver :: select

Watch for changes in the states of several sockets.
init with_sets(read: Bool, write: Bool, except: Bool)

socket :: SocketObserver :: with_sets

Initialize a socket observer
fun write_set: nullable SocketSet

socket :: SocketObserver :: write_set

Set of file descriptors on which to watch write events
protected fun write_set=(write_set: nullable SocketSet)

socket :: SocketObserver :: write_set=

Set of file descriptors on which to watch write events

Redefined properties

redef type SELF: SocketObserver

socket $ SocketObserver :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun except_set: nullable SocketSet

socket :: SocketObserver :: except_set

Set of file descriptors on which to watch exception events
protected fun except_set=(except_set: nullable SocketSet)

socket :: SocketObserver :: except_set=

Set of file descriptors on which to watch exception events
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun read_set: nullable SocketSet

socket :: SocketObserver :: read_set

Set of file descriptors on which to watch read events
protected fun read_set=(read_set: nullable SocketSet)

socket :: SocketObserver :: read_set=

Set of file descriptors on which to watch read events
fun select(max: Socket, seconds: Int, microseconds: Int): Bool

socket :: SocketObserver :: select

Watch for changes in the states of several sockets.
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
init with_sets(read: Bool, write: Bool, except: Bool)

socket :: SocketObserver :: with_sets

Initialize a socket observer
fun write_set: nullable SocketSet

socket :: SocketObserver :: write_set

Set of file descriptors on which to watch write events
protected fun write_set=(write_set: nullable SocketSet)

socket :: SocketObserver :: write_set=

Set of file descriptors on which to watch write events
package_diagram socket::SocketObserver SocketObserver core::Object Object socket::SocketObserver->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

socket $ SocketObserver
# 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