generated from AfonsoCMSousa/CPP-Template
fix: fixed ANOTHER issue with net.cpp
This commit is contained in:
parent
ecc303ca2a
commit
5e7aa014fc
@ -25,15 +25,20 @@ void Socket::connect_server(const char *ip, uint16_t port) {
|
||||
void Socket::connect_unix(const char *ip, uint16_t port) {
|
||||
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
perror("socket() Failed");
|
||||
throw std::runtime_error("Failed to create UNIX socket");
|
||||
}
|
||||
|
||||
this->server_addr_unix.sun_family = AF_UNIX;
|
||||
strncpy(this->server_addr_unix.sun_path, ip, sizeof(this->server_addr_unix.sun_path) - 1);
|
||||
|
||||
printf("Connecting to UNIX socket at %s\n", ip);
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&server_addr_unix, sizeof(server_addr_unix)) < 0) {
|
||||
throw std::runtime_error("Failed to connect to UNIX socket");
|
||||
}
|
||||
|
||||
printf("Connected to UNIX socket at %s\n", ip);
|
||||
}
|
||||
|
||||
void Socket::send_server() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user