mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-28 00:40:42 +00:00
00ac12094e
- lets you split up your `startup.gc` file into two sections - one that runs on initial startup / reloads - the other that runs when you listen to a target - allows for customization of the keybinds added a month or so ago - removes a useless flag (--startup-cmd) and marks others for deprecation. - added another help prompt that lists all the keybinds and what they do Co-authored-by: water <awaterford111445@gmail.com>
57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
#include "XSocketClient.h"
|
|
|
|
#include <string>
|
|
|
|
#include "common/cross_sockets/XSocket.h"
|
|
|
|
// clang-format off
|
|
#ifdef _WIN32
|
|
#define NOMINMAX
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <Windows.h>
|
|
#include <WinSock2.h>
|
|
#include <WS2tcpip.h>
|
|
#endif
|
|
#include "common/repl/nrepl/ReplServer.h"
|
|
|
|
#include "third-party/fmt/core.h"
|
|
// clang-format on
|
|
|
|
XSocketClient::XSocketClient(int _tcp_port) {
|
|
tcp_port = _tcp_port;
|
|
}
|
|
|
|
XSocketClient::~XSocketClient() {
|
|
disconnect();
|
|
client_socket = -1;
|
|
}
|
|
|
|
void XSocketClient::disconnect() {
|
|
close_socket(client_socket);
|
|
client_socket = -1;
|
|
}
|
|
|
|
bool XSocketClient::connect() {
|
|
// Open Socket
|
|
client_socket = open_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
if (client_socket < 0) {
|
|
// TODO - log
|
|
disconnect();
|
|
return false;
|
|
}
|
|
|
|
addr.sin_family = AF_INET;
|
|
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
|
addr.sin_port = htons(tcp_port);
|
|
|
|
// Connect to server
|
|
int result = connect_socket(client_socket, (sockaddr*)&addr, sizeof(addr));
|
|
if (result == -1) {
|
|
// TODO - log and close
|
|
disconnect();
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|