Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set sin_len/un_len on BSD systems #3356

Merged
merged 1 commit into from
May 14, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ endif()
set(IS_FREEBSD 0)
if(CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly")
set(IS_FREEBSD 1)
add_definitions(-D_BSD_SOURCE -DFREEBSD)
endif()
set(IS_NETBSD 0)
set(BUILD_WXC 0)
Expand Down
7 changes: 7 additions & 0 deletions CodeLite/SocketAPI/clSocketClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "clSocketClient.h"

#ifndef _WIN32
#include <sys/param.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
Expand All @@ -52,6 +53,9 @@ bool clSocketClient::ConnectLocal(const wxString& socketPath)
#ifndef __WXMSW__
struct sockaddr_un server;
m_socket = socket(AF_UNIX, SOCK_STREAM, 0);
#ifdef BSD /* BSD specific code. */
server.sun_len = sizeof(struct sockaddr_un);
#endif
server.sun_family = AF_UNIX;
strcpy(server.sun_path, socketPath.mb_str(wxConvUTF8).data());
if(::connect(m_socket, (struct sockaddr*)&server, sizeof(struct sockaddr_un)) < 0) { return false; }
Expand All @@ -70,6 +74,9 @@ bool clSocketClient::ConnectRemote(const wxString& address, int port, bool& woul

const char* ip_addr = address.mb_str(wxConvUTF8).data();
struct sockaddr_in serv_addr;
#ifdef BSD /* BSD specific code. */
serv_addr.sin_len = sizeof(struct sockaddr_in);
#endif
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);

Expand Down
7 changes: 7 additions & 0 deletions CodeLite/SocketAPI/clSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "clSocketServer.h"

#ifndef _WIN32
#include <sys/param.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
Expand Down Expand Up @@ -60,6 +61,9 @@ int clSocketServer::CreateServer(const std::string& pipePath)

// Prepare the sockaddr_in structure
struct sockaddr_un server;
#ifdef BSD /* BSD specific code. */
server.sun_len = sizeof(struct sockaddr_un);
#endif
server.sun_family = AF_UNIX;
strcpy(server.sun_path, pipePath.c_str());

Expand Down Expand Up @@ -97,6 +101,9 @@ int clSocketServer::CreateServer(const std::string& address, int port)

// Prepare the sockaddr_in structure
struct sockaddr_in server;
#ifdef BSD /* BSD specific code. */
server.sin_len = sizeof(struct sockaddr_in);
#endif
server.sin_family = AF_INET;
#ifdef __WXMSW__
server.sin_addr.s_addr = inet_addr(address.c_str());
Expand Down