diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-11-12 16:30:30 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-11-12 16:30:30 +0100 |
commit | 96b4dc4efca1b164f79a7f7394449866f034ac31 (patch) | |
tree | 101b796f40fee444c8193ccc3e13cf5644c83d5f /src/TcpSocket.h | |
parent | 5132756f09c7a0dafe4644db92718ee3d1a58d6c (diff) | |
parent | fedab89cd4625617b3e481f1f59ba0fc97b7305b (diff) | |
download | dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.tar.gz dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.tar.bz2 dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.zip |
Merge branch 'next' into servicelinking
Diffstat (limited to 'src/TcpSocket.h')
-rw-r--r-- | src/TcpSocket.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/TcpSocket.h b/src/TcpSocket.h index 5a4a808..660515d 100644 --- a/src/TcpSocket.h +++ b/src/TcpSocket.h @@ -46,7 +46,7 @@ #include <iostream> #include <string> -#include <boost/optional.hpp> +#include <memory> /** * This class represents a TCP socket. @@ -67,8 +67,12 @@ class TcpSocket ~TcpSocket(); TcpSocket(TcpSocket&& other); TcpSocket& operator=(TcpSocket&& other); + TcpSocket(const TcpSocket& other) = delete; + TcpSocket& operator=(const TcpSocket& other) = delete; - int close(); + bool isValid(void); + + int close(void); /** Send data over the TCP connection. * @param data The buffer that will be sent. @@ -86,7 +90,12 @@ class TcpSocket void listen(void); TcpSocket accept(void); - boost::optional<TcpSocket> accept(int timeout_ms); + + /* Returns either valid socket if a connection was + * accepted before the timeout expired, or an invalid + * socket otherwise. + */ + TcpSocket accept(int timeout_ms); /** Retrieve address this socket is bound to */ InetAddress getOwnAddress() const; @@ -94,8 +103,6 @@ class TcpSocket private: TcpSocket(SOCKET sock, InetAddress own, InetAddress remote); - TcpSocket(const TcpSocket& other) = delete; - TcpSocket& operator=(const TcpSocket& other) = delete; /// The address on which the socket is bound. InetAddress m_own_address; |