tcp_socket


An os_tcp_socket enables reliable connection-oriented communication between a server socket and a client socket. The server constructs an os_tcp_connection_server and binds it to an address that is known to its client. The server then waits for an incoming connection request using accept() . A client creates a stream socket and connects it to the server socket using connect_to() . When the connection is made, the server's accept() function connects its socket argument to the client socket. Data written to the server socket appears as input to the client socket; data written to the client socket appears as input to the server socket.

Library

Network<ToolKit>

Declaration

#include <ospace/socket/tcpsock.h>

class os_tcp_socket : public os_connectable_socket

Enums

enum os_tcp_socket::bind_t
  {
  bound,
  unbound
  };
  

Interface

Constructor
os_tcp_socket( bind_t bound )
If bound is set to os_tcp_socket::bound (default), constructs a TCP socket with a unique local IP address; otherwise, constructs an unbound socket.

Throws: os_network_toolkit_error

Constructor
os_tcp_socket( const os_socket_address& address )
Constructs a socket that has IP value address .

Throws: os_network_toolkit_error

Constructor
os_tcp_socket( os_sock_t descriptor )
Constructs a socket based on the native operating system socket descriptor .

Throws: os_network_toolkit_error

(os_adapter)
operator os_adapter() const
Returns an os_adapter for this socket.
keep_alive
void keep_alive( bool flag )
Sets "keep alive" to flag .

Throws: os_network_toolkit_error

keep_alive
bool keep_alive() const
Returns true if this socket should transmit periodically to keep the connection alive.

Throws: os_network_toolkit_error

reset
void reset()
Destroys the existing underlying socket and replaces it with a newly-constructed socket.

Throws: os_network_toolkit_error


Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.