tcp_connection.h Source File - ClanLib SDK
Description: tcp_connection.h Source File

tcp_connection.h
1
2#pragma once
3
4#include "network_condition_variable.h"
5
6#include <memory>
7#include <vector>
8#include <mutex>
9
10namespace clan
11{
12 class SocketName;
13 class Event;
14 class TCPSocket;
15
17 class TCPConnection : public NetworkEvent
18 {
19 public:
20 static void init_sockets();
21
23 TCPConnection();
24
26 TCPConnection(const SocketName &endpoint);
27
28 ~TCPConnection();
29
31 bool is_null() const { return !impl; }
32
34 SocketName get_local_name();
35
37 SocketName get_remote_name();
38
40 void close();
41
44 int write(const void *data, int size);
45
48 int read(void *data, int size);
49
51 TCPConnection(const std::shared_ptr<TCPSocket> &impl);
52
53 protected:
54 SocketHandle *get_socket_handle() override;
55
56 private:
57 std::shared_ptr<TCPSocket> impl;
58 };
59
60 // To do: QOSAddSocketToFlow
61}
clan::NetworkEvent
Base class for all classes that generate network events.
Definition network_condition_variable.h:15
clan::SocketName
Socket name; container class for an IP address and port.
Definition socket_name.h:45
clan::TCPConnection
TCP/IP socket connection.
Definition tcp_connection.h:18
clan::TCPConnection::init_sockets
static void init_sockets()
clan::TCPConnection::TCPConnection
TCPConnection(const std::shared_ptr< TCPSocket > &impl)
clan::TCPConnection::get_socket_handle
SocketHandle * get_socket_handle() override
clan::TCPConnection::TCPConnection
TCPConnection()
Create null object.
clan::TCPConnection::~TCPConnection
~TCPConnection()
clan::TCPConnection::get_remote_name
SocketName get_remote_name()
Returns the socket name of the peer end point.
clan::TCPConnection::is_null
bool is_null() const
Returns true if it is a null object.
Definition tcp_connection.h:31
clan::TCPConnection::TCPConnection
TCPConnection(const SocketName &endpoint)
Blocking connect to end point.
clan::TCPConnection::get_local_name
SocketName get_local_name()
Returns the socket name of the local end point.
clan::TCPConnection::close
void close()
Close connection.
clan::TCPConnection::read
int read(void *data, int size)
Read data from TCP socket.
clan::TCPConnection::write
int write(const void *data, int size)
Write data to TCP socket.
clan
Definition clanapp.h:36