mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-05 07:16:29 +00:00
works but linux build is broken and this is an old version of the source
This commit is contained in:
@@ -10,11 +10,20 @@
|
||||
#include <vector>
|
||||
#include "Logger.h"
|
||||
#include <iostream>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Zlib/Compressor.h>
|
||||
|
||||
#include "Network/network.hpp"
|
||||
#if defined(_WIN32)
|
||||
#include <ws2tcpip.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include "Network/network.hpp"
|
||||
|
||||
int LastPort;
|
||||
std::string LastIP;
|
||||
@@ -116,10 +125,12 @@ std::string TCPRcv(SOCKET Sock){
|
||||
void TCPClientMain(const std::string& IP,int Port){
|
||||
LastIP = IP;
|
||||
LastPort = Port;
|
||||
WSADATA wsaData;
|
||||
SOCKADDR_IN ServerAddr;
|
||||
int RetCode;
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
WSAStartup(514, &wsaData); //2.2
|
||||
#endif
|
||||
TCPSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if(TCPSock == -1){
|
||||
@@ -127,6 +138,7 @@ void TCPClientMain(const std::string& IP,int Port){
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
ServerAddr.sin_family = AF_INET;
|
||||
ServerAddr.sin_port = htons(Port);
|
||||
inet_pton(AF_INET, IP.c_str(), &ServerAddr.sin_addr);
|
||||
@@ -152,6 +164,9 @@ void TCPClientMain(const std::string& IP,int Port){
|
||||
if(KillSocket(TCPSock) != 0)
|
||||
debug("(TCP) Cannot close socket. Error code: " + std::to_string(WSAGetLastError()));
|
||||
|
||||
#ifdef _WIN32
|
||||
if(WSACleanup() != 0)
|
||||
debug("(TCP) Client: WSACleanup() failed!...");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user