clan::TCPConnection Class Reference - ClanLib SDK
Description: clan::TCPConnection Class Reference

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
clan::TCPConnection Class Reference

TCP/IP socket connection. More...

`#include <tcp_connection.h>`

Inheritance diagram for clan::TCPConnection:

## Public Member Functions
| TCPConnection ()
| Create null object.
| TCPConnection (const SocketName &endpoint)
| Blocking connect to end point.
| TCPConnection (const std::shared_ptr< TCPSocket > &impl)
| ~TCPConnection ()
void | close ()
| Close connection.
SocketName | get_local_name ()
| Returns the socket name of the local end point.
SocketName | get_remote_name ()
| Returns the socket name of the peer end point.
bool | is_null () const
| Returns true if it is a null object.
int | read (void *data, int size)
| Read data from TCP socket.
int | write (const void *data, int size)
| Write data to TCP socket.

## Static Public Member Functions
static void | init_sockets ()

## Protected Member Functions
SocketHandle * | get_socket_handle () override

## Detailed Description

TCP/IP socket connection.

## Constructor & Destructor Documentation

## ◆ TCPConnection() [1/3]

clan::TCPConnection::TCPConnection | ( |  | ) |

Create null object.

## ◆ TCPConnection() [2/3]

clan::TCPConnection::TCPConnection | ( | const SocketName & | endpoint | ) |

Blocking connect to end point.

## ◆ ~TCPConnection()

clan::TCPConnection::~TCPConnection | ( |  | ) |

## ◆ TCPConnection() [3/3]

clan::TCPConnection::TCPConnection | ( | const std::shared_ptr< TCPSocket > & | impl | ) |

## Member Function Documentation

## ◆ close()

void clan::TCPConnection::close | ( |  | ) |

Close connection.

## ◆ get_local_name()

SocketName clan::TCPConnection::get_local_name | ( |  | ) |

Returns the socket name of the local end point.

## ◆ get_remote_name()

SocketName clan::TCPConnection::get_remote_name | ( |  | ) |

Returns the socket name of the peer end point.

## ◆ get_socket_handle()

SocketHandle * clan::TCPConnection::get_socket_handle | ( |  | ) |
| overrideprotectedvirtual

Implements clan::NetworkEvent.

## ◆ init_sockets()

void clan::TCPConnection::init_sockets | ( |  | ) |
| static

## ◆ is_null()

bool clan::TCPConnection::is_null | ( |  | ) | const
| inline

Returns true if it is a null object.

## ◆ read()

int clan::TCPConnection::read | ( | void * | data,
|  | int | size )

Read data from TCP socket.

Returns
  Bytes read, 0 if remote closed connection, or -1 if buffer is empty

## ◆ write()

int clan::TCPConnection::write | ( | const void * | data,
|  | int | size )

Write data to TCP socket.

Returns
  Bytes written, or -1 if buffer is full

The documentation for this class was generated from the following file:

- tcp_connection.h