diff options
Diffstat (limited to 'net/Socket.hpp')
-rw-r--r-- | net/Socket.hpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/Socket.hpp b/net/Socket.hpp index 736be21812..0175995346 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -96,8 +96,10 @@ public: static const int MaximumSendBufferSize = 128 * 1024; static std::atomic<bool> InhibitThreadChecks; - Socket() : - _fd(socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)), + enum Type { IPv4, IPv6, All }; + + Socket(Type type) : + _fd(createSocket(type)), _sendBufferSize(DefaultSendBufferSize), _owner(std::this_thread::get_id()) { @@ -112,6 +114,9 @@ public: close(_fd); } + /// Create socket of the given type. + int createSocket(Type type); + /// Returns the OS native socket fd. int getFD() const { return _fd; } |