Browse Source

Merge pull request #501 from paullouisageneau/freebsd

Travis CI for FreeBSD
Paul-Louis Ageneau 3 years ago
parent
commit
8bcae7272c
5 changed files with 16 additions and 6 deletions
  1. 8 0
      .travis.yml
  2. 3 1
      examples/media/main.cpp
  3. 2 2
      src/impl/tcpserver.cpp
  4. 2 2
      src/impl/tcptransport.cpp
  5. 1 1
      test/websocketserver.cpp

+ 8 - 0
.travis.yml

@@ -0,0 +1,8 @@
+name: Build and test on FreeBSD
+os: freebsd
+language: cpp
+script:
+- sudo sysctl net.inet6.ip6.v6only=0
+- cmake -B build
+- cd build && make -j2 && ./tests
+

+ 3 - 1
examples/media/main.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * libdatachannel client example
+ * libdatachannel media example
  * Copyright (c) 2020 Staz Modrzynski
  * Copyright (c) 2020 Staz Modrzynski
  * Copyright (c) 2020 Paul-Louis Ageneau
  * Copyright (c) 2020 Paul-Louis Ageneau
  *
  *
@@ -30,7 +30,9 @@
 #ifdef _WIN32
 #ifdef _WIN32
 #include <winsock2.h>
 #include <winsock2.h>
 #else
 #else
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <arpa/inet.h>
+#include <netinet/in.h>
 typedef int SOCKET;
 typedef int SOCKET;
 #endif
 #endif
 
 

+ 2 - 2
src/impl/tcpserver.cpp

@@ -133,8 +133,8 @@ void TcpServer::listen(uint16_t port) {
 		// Listen on both IPv6 and IPv4
 		// Listen on both IPv6 and IPv4
 		const sockopt_t disabled = 0;
 		const sockopt_t disabled = 0;
 		if (ai->ai_family == AF_INET6)
 		if (ai->ai_family == AF_INET6)
-			::setsockopt(mSock, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&disabled,
-			             sizeof(disabled));
+			::setsockopt(mSock, IPPROTO_IPV6, IPV6_V6ONLY,
+			             reinterpret_cast<const char *>(&disabled), sizeof(disabled));
 
 
 		// Set non-blocking
 		// Set non-blocking
 		ctl_t b = 1;
 		ctl_t b = 1;

+ 2 - 2
src/impl/tcptransport.cpp

@@ -188,8 +188,8 @@ void TcpTransport::connect(const sockaddr *addr, socklen_t addrlen) {
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
 		// MacOS lacks MSG_NOSIGNAL and requires SO_NOSIGPIPE instead
 		// MacOS lacks MSG_NOSIGNAL and requires SO_NOSIGPIPE instead
-		int opt = 1;
-		if (::setsockopt(mSock, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt)) < 0)
+		const sockopt_t enabled = 1;
+		if (::setsockopt(mSock, SOL_SOCKET, SO_NOSIGPIPE, &enabled, sizeof(enabled)) < 0)
 			throw std::runtime_error("Failed to disable SIGPIPE for socket");
 			throw std::runtime_error("Failed to disable SIGPIPE for socket");
 #endif
 #endif
 
 

+ 1 - 1
test/websocketserver.cpp

@@ -92,7 +92,7 @@ void test_websocketserver() {
 
 
 	ws.open("wss://localhost:48080/");
 	ws.open("wss://localhost:48080/");
 
 
-	int attempts = 10;
+	int attempts = 15;
 	while ((!ws.isOpen() || !received) && attempts--)
 	while ((!ws.isOpen() || !received) && attempts--)
 		this_thread::sleep_for(1s);
 		this_thread::sleep_for(1s);