Got working with macOS

This commit is contained in:
mmcwilliams 2024-04-06 11:26:16 -04:00
parent 1cbf34c7f1
commit 4e9f4d46f1
2 changed files with 8 additions and 5 deletions

View File

@ -21,6 +21,7 @@ using namespace std;
using namespace std::chrono; using namespace std::chrono;
const int DISPLAY_DURATION = 2000; const int DISPLAY_DURATION = 2000;
const int PORT = 8081;
steady_clock::time_point startTime; steady_clock::time_point startTime;
bool shouldDisplayQuad = false; bool shouldDisplayQuad = false;
@ -122,10 +123,12 @@ int main(int argc, char** argv) {
struct sockaddr_in serverAddr; struct sockaddr_in serverAddr;
serverAddr.sin_family = AF_INET; serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr = INADDR_ANY; serverAddr.sin_addr.s_addr = INADDR_ANY;
serverAddr.sin_port = htons(8080); serverAddr.sin_port = htons(PORT);
if (bind(serverSocket, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) < 0) { int bindResult = ::bind(serverSocket, reinterpret_cast<struct sockaddr*>(&serverAddr), sizeof(serverAddr));
cerr << "Error binding socket" << endl; if (bindResult < 0) {
std::cerr << "Error binding socket" << std::endl;
close(serverSocket);
return 1; return 1;
} }
@ -134,7 +137,7 @@ int main(int argc, char** argv) {
return 1; return 1;
} }
cout << "TCP server listening on port 8080" << endl; cout << "TCP server listening on port " << PORT << endl;
thread serverThread(runTCPServer, serverSocket); thread serverThread(runTCPServer, serverSocket);

View File

@ -3,7 +3,7 @@ import json
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 8080) server_address = ('localhost', 8081)
print(f'Connecting to {server_address}...') print(f'Connecting to {server_address}...')
client_socket.connect(server_address) client_socket.connect(server_address)