Skip to content

Commit

Permalink
Sharing to ec2
Browse files Browse the repository at this point in the history
  • Loading branch information
GinOwO committed Nov 7, 2024
1 parent f71552b commit c7d078b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def play(conns: Dict[str, socket.socket], RUNNING: List[bool]):

for sock in ready_sockets:
try:
data = sock.recv(156)
data = sock.recv(146, socket.MSG_WAITALL)
print(data)
if not data:
print("Connection closed by client.")
Expand Down
11 changes: 6 additions & 5 deletions src/multiplayer/MM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <unistd.h>
#include <exception>

constexpr int32_t INSTR_BUFFER_SIZE = 156;
constexpr int32_t INSTR_BUFFER_SIZE = 146;

MatchMaking &MatchMaking::get_instance()
{
Expand Down Expand Up @@ -178,8 +178,7 @@ void MatchMaking::sync_enemy_queue(
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
(const char *)&timeout, sizeof timeout);

int recv_size =
recv(sock, buffer, sizeof(buffer) - 1, MSG_WAITALL);
int recv_size = recv(sock, buffer, sizeof(buffer) - 1, 0);
if (recv_size <= 0) {
if (recv_size == 0 || errno == EWOULDBLOCK ||
errno == EAGAIN) {
Expand Down Expand Up @@ -214,8 +213,10 @@ void MatchMaking::sync_enemy_queue(
}
enemy_queue->push({ x, y });
} catch (const std::invalid_argument &e) {
std::cerr << "MM:\t\tMalformed state received: "
<< received_data << '\n';
std::cerr
<< "MM:\t\t Exception" << e.what()
<< "\nMM:\t\tMalformed state received: "
<< received_data << '\n';
}
}
}
Expand Down

0 comments on commit c7d078b

Please sign in to comment.