@head @module socket @title socket: Network connections
This module supports creating TCP clients that create stream-based network connections to other computers or processes. In this context, the term socket refers to IPv4 stream sockets only. @see Use the @ref{serversocket} module to create TCP servers. @end
The buffering parameter specifies the buffering mode. If omitted, the connection is unbuffered. Valid values for the parameter are @ref{io::Buffered}, @ref{io::LineBuffered} and @ref{io::Unbuffered}.
Socket is derived from @ref{io::Stream}. Like @ref{File} objects, Socket objects are narrow streams. Socket objects support both writing (sending) and reading (receiving) data. @end
Socket instances are also implicitly created by the @ref{serversocket::ServerSocket} class.
Socket inherits most of the @ref{Stream} operations unchanged, including:
It also supports the following operations: @fun close() @desc Close the connection. Free any resources allocated to the connection. @end @fun localAddress() as Str @desc Return the local IP address as a string in dotted decimal format (e.g. "100.50.200.5"). @end @fun localPort() as Int @desc Return the local port number. @end @fun remoteAddress() as Str @desc Return the remote IP address as a string in dotted decimal format (e.g. "100.50.200.5"). @end @fun remotePort() as Int @desc Return the remote port number. @end @end-class