Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ixwebsocket/IXSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ namespace ix
if (_addressFamily == AF_INET)
{
struct sockaddr_in server;
memset(&server, '\0', sizeof(server));
server.sin_family = _addressFamily;
server.sin_port = htons(_port);

Expand Down Expand Up @@ -130,6 +131,7 @@ namespace ix
else // AF_INET6
{
struct sockaddr_in6 server;
memset(&server, '\0', sizeof(server));
server.sin6_family = _addressFamily;
server.sin6_port = htons(_port);

Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set (TEST_TARGET_NAMES
IXExponentialBackoffTest
IXWebSocketCloseTest
IXWebSocketHostTest
IXWebSocketIPv6Test
)

# Some unittest don't work on windows yet
Expand Down
25 changes: 25 additions & 0 deletions test/IXWebSocketIPv6Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "IXTest.h"
#include "catch.hpp"
#include <ixwebsocket/IXWebSocket.h>
#include <ixwebsocket/IXWebSocketServer.h>

using namespace ix;

TEST_CASE("IPv6")
{
SECTION("Listening on ::1 works with AF_INET6 works")
{
int port = getFreePort();
ix::WebSocketServer server(port,
"::1",
SocketServer::kDefaultTcpBacklog,
SocketServer::kDefaultMaxConnections,
WebSocketServer::kDefaultHandShakeTimeoutSecs,
AF_INET6);

auto res = server.listen();
CHECK(res.first);
server.start();
server.stop();
}
}
Loading