00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __libutilxx__sella__net__TCPSocket_H__
00010 #define __libutilxx__sella__net__TCPSocket_H__
00011
00012 #include "../../common.h"
00013 #include "Socket.h"
00014 #include "IPAddressPort.h"
00015
00016 #include <sys/socket.h>
00017 #include <memory>
00018
00019 #define TCPSOCKET_LISTEN_BACKLOG_DEF SOMAXCONN
00020
00021 namespace sella {
00022 namespace net {
00023 class TCPSocket;
00024 }
00025 }
00026
00027 class sella::net::TCPSocket : public Socket {
00028 public:
00029 typedef std::shared_ptr<TCPSocket> shared;
00030 typedef TCPSocket *ptr;
00031
00032 public:
00033 TCPSocket(int family) throw (SocketException);
00034 TCPSocket(int family, const IPAddressPort &addressport) throw (SocketException);
00035 TCPSocket(int family, const IPAddress &address, const Port &port) throw (SocketException);
00036 TCPSocket(int family, const std::string &address, unsigned short port) throw (SocketException);
00037 TCPSocket(const IPAddressPort &addressport) throw (SocketException);
00038 TCPSocket(const IPAddress &address, const Port &port) throw (SocketException);
00039 TCPSocket(const TCPSocket &sock) = delete;
00040 virtual ~TCPSocket();
00041 void operator=(const TCPSocket &sock) = delete;
00042
00043 void listen(int backlog = TCPSOCKET_LISTEN_BACKLOG_DEF) throw (SocketException);
00044 TCPSocket::shared accept(void) throw (SocketException);
00045
00046 static const TCPSocket::shared shared_ptr(int family) throw (SocketException);
00047 static const TCPSocket::shared shared_ptr(int family, const IPAddressPort &addressport) throw (SocketException);
00048 static const TCPSocket::shared shared_ptr(int family, const IPAddress &address, const Port &port) throw (SocketException);
00049 static const TCPSocket::shared shared_ptr(int family, const std::string &address, unsigned short port) throw (SocketException);
00050 static const TCPSocket::shared shared_ptr(const IPAddressPort &addressport) throw (SocketException);
00051 static const TCPSocket::shared shared_ptr(const IPAddress &address, const Port &port) throw (SocketException);
00052
00053 protected:
00054
00055 private:
00056 TCPSocket(int s, bool unused __attribute__((unused))) throw (SocketException);
00057 };
00058
00059 #endif
00060
00061
00062
00063