libutil++  1.9.3
 All Classes Functions Variables
TCPSocket.h
1 /*
2 ** libutil++
3 ** $Id: TCPSocket.h 1653 2016-02-28 19:54:59Z sella $
4 ** Copyright (c) 2011-2016 Digital Genesis, LLC. All Rights Reserved.
5 ** Released under the LGPL Version 2.1 License.
6 ** http://www.digitalgenesis.com
7 */
8 
9 #ifndef __libutilxx__sella__net__TCPSocket_H__
10 #define __libutilxx__sella__net__TCPSocket_H__
11 
12 #include "../../common.h"
13 #include "Socket.h"
14 #include "IPAddressPort.h"
15 
16 #include <sys/socket.h>
17 #include <memory>
18 
19 #define TCPSOCKET_LISTEN_BACKLOG_DEF SOMAXCONN /* 128 for Linux 2.6 */
20 
21 namespace sella {
22  namespace net {
23  class TCPSocket;
24  }
25 }
26 
27 class sella::net::TCPSocket : public Socket {
28  public:
29  typedef std::shared_ptr<TCPSocket> shared;
30  typedef TCPSocket *ptr;
31 
32  public:
33  TCPSocket(int family) throw (SocketException);
34  TCPSocket(int family, const IPAddressPort &addressport) throw (SocketException);
35  TCPSocket(int family, const IPAddress &address, const Port &port) throw (SocketException);
36  TCPSocket(int family, const std::string &address, unsigned short port) throw (SocketException);
37  TCPSocket(const IPAddressPort &addressport) throw (SocketException);
38  TCPSocket(const IPAddress &address, const Port &port) throw (SocketException);
39  TCPSocket(const TCPSocket &sock) = delete;
40  virtual ~TCPSocket();
41  void operator=(const TCPSocket &sock) = delete;
42 
43  virtual void listen(int backlog = TCPSOCKET_LISTEN_BACKLOG_DEF) throw (SocketException);
44  virtual TCPSocket::shared accept(void) throw (SocketException);
45 
46  static const TCPSocket::shared shared_ptr(int family) throw (SocketException);
47  static const TCPSocket::shared shared_ptr(int family, const IPAddressPort &addressport) throw (SocketException);
48  static const TCPSocket::shared shared_ptr(int family, const IPAddress &address, const Port &port) throw (SocketException);
49  static const TCPSocket::shared shared_ptr(int family, const std::string &address, unsigned short port) throw (SocketException);
50  static const TCPSocket::shared shared_ptr(const IPAddressPort &addressport) throw (SocketException);
51  static const TCPSocket::shared shared_ptr(const IPAddress &address, const Port &port) throw (SocketException);
52 
53  protected:
54  TCPSocket(int family, int type, int protocol) throw (SocketException);
55  TCPSocket(int s, bool unused __attribute__((unused))) throw (SocketException);
56 };
57 
58 #endif
59 
60 /*
61 ** vim: noet ts=3 sw=3
62 */