diff --git a/CMakeLists.txt b/CMakeLists.txt index fa1b6f61..30a15762 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,10 +75,12 @@ include_directories( ) set(API_HEADERS + hal/inc/hal_base.h hal/inc/hal_time.h hal/inc/hal_thread.h hal/inc/hal_filesystem.h hal/inc/hal_ethernet.h + hal/inc/hal_socket.h hal/inc/tls_config.h hal/inc/platform_endian.h hal/inc/lib_memory.h @@ -114,11 +116,11 @@ set(API_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/config/stack_config.h ) -if(MSVC) +if(MSVC AND MSVC_VERSION LESS 1800) include_directories( ${CMAKE_CURRENT_LIST_DIR}/src/vs ) -endif(MSVC) +endif() if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/third_party/mbedtls/mbedtls-2.6.0) set(WITH_MBEDTLS 1) diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index 0bf25ec6..645dddf6 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -78,15 +78,15 @@ message("Found winpcap -> can compile with GOOSE support") set(WITH_WPCAP 1) endif() -IF(MSVC) -set_source_files_properties(${libhal_windows_SRCS} - PROPERTIES LANGUAGE CXX) -ENDIF() - set (libhal_SRCS ${libhal_windows_SRCS} ) +IF(MSVC) +set_source_files_properties(${libhal_SRCS} + PROPERTIES LANGUAGE CXX) +ENDIF() + ELSEIF(UNIX) IF(APPLE) set (libhal_SRCS @@ -122,9 +122,14 @@ file(GLOB tls_SRCS ${CMAKE_CURRENT_LIST_DIR}/../third_party/mbedtls/mbedtls-2.6. add_definitions(-DMBEDTLS_CONFIG_FILE="mbedtls_config.h") set (libhal_SRCS ${libhal_SRCS} - ${CMAKE_CURRENT_LIST_DIR}/tls/mbedtls/tls_mbedtls.c + ${CMAKE_CURRENT_LIST_DIR}/tls/mbedtls/tls_mbedtls.c ) +IF(MSVC) +set_source_files_properties(${libhal_SRCS} + PROPERTIES LANGUAGE CXX) +ENDIF() + list (APPEND libhal_SRCS ${tls_SRCS}) endif(WITH_MBEDTLS) diff --git a/hal/socket/linux/socket_linux.c b/hal/socket/linux/socket_linux.c index fae84de7..d6942108 100644 --- a/hal/socket/linux/socket_linux.c +++ b/hal/socket/linux/socket_linux.c @@ -32,7 +32,7 @@ #include #include #include -#include // required for TCP keepalive +#include /* required for TCP keepalive */ #include "hal_thread.h" #include "lib_memory.h" @@ -258,7 +258,7 @@ closeAndShutdownSocket(int socketFd) if (DEBUG_SOCKET) printf("socket_linux.c: call shutdown for %i!\n", socketFd); - // shutdown is required to unblock read or accept in another thread! + /* shutdown is required to unblock read or accept in another thread! */ shutdown(socketFd, SHUT_RDWR); close(socketFd); @@ -312,10 +312,6 @@ Socket_connectAsync(Socket self, const char* address, int port) activateTcpNoDelay(self); -#if (CONFIG_ACTIVATE_TCP_KEEPALIVE == 1) - activateKeepAlive(self->fd); -#endif - fcntl(self->fd, F_SETFL, O_NONBLOCK); if (connect(self->fd, (struct sockaddr *) &serverAddress, sizeof(serverAddress)) < 0) { @@ -510,7 +506,7 @@ Socket_write(Socket self, uint8_t* buf, int size) if (self->fd == -1) return -1; - // MSG_NOSIGNAL - prevent send to signal SIGPIPE when peer unexpectedly closed the socket + /* MSG_NOSIGNAL - prevent send to signal SIGPIPE when peer unexpectedly closed the socket */ return send(self->fd, buf, size, MSG_NOSIGNAL); } diff --git a/hal/socket/win32/socket_win32.c b/hal/socket/win32/socket_win32.c index 75c4f653..3f8f2caa 100644 --- a/hal/socket/win32/socket_win32.c +++ b/hal/socket/win32/socket_win32.c @@ -342,10 +342,6 @@ Socket_connectAsync(Socket self, const char* address, int port) self->fd = socket(AF_INET, SOCK_STREAM, 0); -#if CONFIG_ACTIVATE_TCP_KEEPALIVE == 1 - activateKeepAlive(self->fd); -#endif - setSocketNonBlocking(self); if (connect(self->fd, (struct sockaddr *) &serverAddress, sizeof(serverAddress)) == SOCKET_ERROR) { @@ -517,7 +513,7 @@ Socket_read(Socket self, uint8_t* buf, int size) { int bytes_read = recv(self->fd, (char*) buf, size, 0); - if (bytes_read == 0) // peer has closed socket + if (bytes_read == 0) /* peer has closed socket */ return -1; if (bytes_read == SOCKET_ERROR) {