Property definitions

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