TcpSocket manages a TCP/IP endpoint.
Bind this socket to the specified local address. If addr is null then the default IpAddr for the local host is selected. If port is null an ephemeral port is selected. Throw IOErr if the port is already bound or the bind fails. Return this.
Close this socket and its associated IO streams. This method is guaranteed to never throw an IOErr. Return true if the socket was closed successfully or false if the socket was closed abnormally.
socket configurationfor this socket.
Connect this socket to the specified address and port. This method will block until the connection is made. Throw IOErr if there is a connection error. If a non-null timeout is specified, then block no longer then the specified timeout before raising an IOErr. If timeout is null, then a system default is used. The default timeout is configured via
Get the input stream used to read data from the socket. The input stream is automatically buffered according to SocketOptions.inBufferSize. If not connected then throw IOErr.
Is this socket bound to a local address and port.
Is this socket closed.
Is this socket connected to the remote host.
Get the bound local address or null if unbound.
Get the bound local port or null if unbound.
new make(SocketConfig config := SocketConfig.cur())
Make a new unbound, unconnected TCP socket. The socket will be configured using the given
socket configuration. The following configuration applies to a TCP socket:
Access the SocketOptions used to tune this socket. The following options apply to TcpSockets:
- trafficClass Accessing other option fields will throw UnsupportedErr.
Get the output stream used to write data to the socket. The output stream is automatically buffered according to SocketOptions.outBufferSize If not connected then throw IOErr.
Get the remote address or null if not connected.
Get the remote port or null if not connected.
Place input stream for socket at "end of stream". Any data sent to input side of socket is acknowledged and then silently discarded. Raise IOErr if error occurs.
Disables the output stream for this socket. Any previously written data will be sent followed by TCP's normal connection termination sequence. Raise IOErr if error occurs.
Get a new TCP socket that is upgraded to use TLS. If connecting through a web proxy, specify the destination address and port.