class SOCKET_SERVER

All features

A socket server waits for connections to happen on some given address/port. It then defers treatment to handlers (see the when_connect feature).

Please use ACCESS.server to create a SOCKET_SERVER.

Direct parents

non-conformant parents

SOCKET_HANDLER, SOCKET_PLUG_IN

Summary

creation features

exported features

Plugin

Details

make (a_access: ACCESS, a_socket_fd: INTEGER)

Connect to an access, which must also provide the file descriptor

require

  • a_access /= Void
  • valid_file_descriptor: a_socket_fd >= 0

can_connect: BOOLEAN

True if some client can connect to the server.

shutdown

Wait for the connections to finish, then stop the server. No more connections will be accepted.

require

  • can_connect

ensure

  • not can_connect

halt

Force all the connected sockets to disconnect, then shutdown

require

  • can_connect

ensure

  • not can_connect

new_stream: SOCKET_INPUT_OUTPUT_STREAM
fd: INTEGER

The file descriptor of the socket; it is used to wait for some connection.

access: ACCESS
bind: SOCKET

Create a socket for the stream to connect upon (used by the stream at creation)

ensure

  • has_socket(Result)

unbind (socket: SOCKET)

Close the socket and unbind it

require

  • socket.is_connected
  • has_socket(socket)

ensure

  • not has_socket(socket)
  • not socket.is_connected

has_socket (socket: SOCKET): BOOLEAN
socket_disconnected (socket: SOCKET)

require

  • not socket.is_connected
  • has_socket(socket)

ensure

  • not has_socket(socket)

connected_sockets: FAST_ARRAY [E_][SOCKET]

The currently connected sockets

disconnected_sockets: FAST_ARRAY [E_][WEAK_REFERENCE [G_][SOCKET]]

Common array containing all the currently disconnected sockets.

bind_socket: SOCKET

ensure

  • Result.is_connected implies connected_sockets.fast_has(Result) and then connected_sockets.count = old connected_sockets.count + 1

unbind_socket (socket: SOCKET)

require

  • connected_sockets.fast_has(socket)

ensure

  • not connected_sockets.fast_has(socket)

kill_connections
get_disconnected_socket: SOCKET
put_disconnected_socket (socket: SOCKET)
make (a_access: ACCESS, a_socket_fd: INTEGER)

Connect to an access, which must also provide the file descriptor

require

  • a_access /= Void
  • valid_file_descriptor: a_socket_fd >= 0

last_error: STRING
last_error_memory: STRING
net_tcp (ip_a: INTEGER, ip_b: INTEGER, ip_c: INTEGER, ip_d: INTEGER, a_port: INTEGER): INTEGER
net_udp (ip_a: INTEGER, ip_b: INTEGER, ip_c: INTEGER, ip_d: INTEGER, a_port: INTEGER): INTEGER
net_local (a_port: INTEGER): INTEGER
net_select (a_fd: INTEGER, a_timeout: REAL): INTEGER
net_read (a_fd: INTEGER, a_count: INTEGER, a_buffer: POINTER): INTEGER
net_write (a_fd: INTEGER, a_count: INTEGER, a_buffer: NATIVE_ARRAY [E_][CHARACTER]): INTEGER
net_accept (a_fd: INTEGER, a_val: NATIVE_ARRAY [E_][INTEGER])
net_disconnect (a_fd: INTEGER)
net_shutdown (a_fd: INTEGER)
net_last_error: POINTER
net_last_error_number: INTEGER
net_hostname (a_hostname: POINTER): INTEGER
net_tcp_server (port: INTEGER): INTEGER
net_udp_server (port: INTEGER): INTEGER
net_local_server (port: INTEGER): INTEGER