fix reading req

This commit is contained in:
Serafim 2024-12-14 06:40:39 +03:00
parent 27e21e7ed1
commit 52d95878e8
7 changed files with 32 additions and 168 deletions

Binary file not shown.

View File

@ -9,7 +9,7 @@
#include <cstring>
// IP address of the server1
std::string SERVER_IP1 = "127.0.0.1";
std::string SERVER_IP1 = "94.250.253.128";
// Port of the server1
int PORT1 = 9001;

View File

@ -1,151 +0,0 @@
2024/12/12 19:56:03 Creating socket...
2024/12/12 19:56:03 Socket created
2024/12/12 19:56:03 Listening for connections...
2024/12/12 19:56:10 New connection accepted
2024/12/12 19:56:10 New thread created for socket 5
2024/12/12 19:56:12 Got new message from client 5:
2024/12/12 19:56:12 Sent new info to client 5
2024/12/12 19:56:14 Got new message from client 5:
2024/12/12 19:56:15 Got new message from client 5:
2024/12/12 19:56:16 Got new message from client 5:
2024/12/12 19:56:16 Sent new info to client 5
2024/12/12 19:56:18 Got new message from client 5:
2024/12/12 19:56:18 Client 5 info is not up to dateSent new info to client 5
2024/12/12 19:56:19 Got new message from client 5:
2024/12/12 19:56:19 Actual info already on client 5
2024/12/12 19:56:20 Got new message from client 5:
2024/12/12 19:56:20 Sent new info to client 5
2024/12/12 19:56:21 Got new message from client 5:
2024/12/12 19:56:21 Sent new info to client 5
2024/12/12 19:56:22 Got new message from client 5:
2024/12/12 19:56:23 Got new message from client 5:
2024/12/12 19:56:23 Client 5 info is not up to dateSent new info to client 5
2024/12/12 19:56:24 Got new message from client 5:
2024/12/12 19:56:24 Sent new info to client 5
2024/12/12 19:56:25 Got new message from client 5:
2024/12/12 19:56:26 Got new message from client 5:
2024/12/12 19:56:26 Client 5 info is not up to date
2024/12/12 19:56:26 Sent new info to client 5
2024/12/12 19:56:27 Got new message from client 5:
2024/12/12 19:56:27 Sent new info to client 5
2024/12/12 19:56:28 Got new message from client 5:
2024/12/12 19:56:29 Got new message from client 5:
2024/12/12 19:56:29 Sent new info to client 5
2024/12/12 19:56:30 Got new message from client 5:
2024/12/12 19:56:31 Got new message from client 5:
2024/12/12 19:56:32 Got new message from client 5:
2024/12/12 19:56:32 Client 5 info is not up to dateSent new info to client 5
2024/12/12 19:56:33 Got new message from client 5:
2024/12/12 19:56:33 Sent new info to client 5
2024/12/12 19:56:34 Got new message from client 5:
2024/12/12 19:56:35 Got new message from client 5:
2024/12/12 19:56:35 Sent new info to client 5
2024/12/12 19:56:36 Got new message from client 5:
2024/12/12 19:56:36 Client 5 info is not up to date
2024/12/12 19:56:36 Sent new info to client 5
2024/12/12 19:56:37 Got new message from client 5:
2024/12/12 19:56:38 Got new message from client 5:
2024/12/12 19:56:38 Sent new info to client 5
2024/12/12 19:56:39 Got new message from client 5:
2024/12/12 19:56:39 Client 5 info is not up to date
2024/12/12 19:56:39 Sent new info to client 5
2024/12/12 19:56:40 Got new message from client 5:
2024/12/12 19:56:40 Actual info already on client 5
2024/12/12 19:56:40 Connection with client 5 closed
2024/12/12 19:57:04 Creating socket...
2024/12/12 19:57:04 Socket created
2024/12/12 19:57:04 Listening for connections...
2024/12/12 19:57:10 New connection accepted
2024/12/12 19:57:10 New thread created for socket 5
2024/12/12 19:57:12 Got new message from client 5:
2024/12/12 19:57:12 Client 5 info is not up to date
2024/12/12 19:57:12 Sent new info to client 5
2024/12/12 19:57:13 Got new message from client 5:
2024/12/12 19:57:13 Sent new info to client 5
2024/12/12 19:57:14 Got new message from client 5:
2024/12/12 19:57:15 Got new message from client 5:
2024/12/12 19:57:15 Client 5 info is not up to date
2024/12/12 19:57:15 Sent new info to client 5
2024/12/12 19:57:16 Got new message from client 5:
2024/12/12 19:57:16 Sent new info to client 5
2024/12/12 19:57:17 Got new message from client 5:
2024/12/12 19:57:18 Got new message from client 5:
2024/12/12 19:57:18 Sent new info to client 5
2024/12/12 19:57:19 Got new message from client 5:
2024/12/12 19:57:19 Client 5 info is not up to date
2024/12/12 19:57:19 Sent new info to client 5
2024/12/12 19:57:20 Got new message from client 5:
2024/12/12 19:57:20 Actual info already on client 5
2024/12/12 19:57:21 Got new message from client 5:
2024/12/12 19:57:21 Sent new info to client 5
2024/12/12 19:57:22 Got new message from client 5:
2024/12/12 19:57:23 Got new message from client 5:
2024/12/12 19:57:24 Got new message from client 5:
2024/12/12 19:57:25 Got new message from client 5:
2024/12/12 19:57:26 Got new message from client 5:
2024/12/12 19:57:27 Got new message from client 5:
2024/12/12 19:57:27 Client 5 info is not up to dateSent new info to client 5
2024/12/12 19:57:28 Got new message from client 5:
2024/12/12 19:57:28 Sent new info to client 5
2024/12/12 19:57:29 Got new message from client 5:
2024/12/12 19:57:29 Actual info already on client 5
2024/12/12 19:57:30 Got new message from client 5:
2024/12/12 19:57:30 Client 5 info is not up to date
2024/12/12 19:57:30 Sent new info to client 5
2024/12/12 19:57:31 Got new message from client 5:
2024/12/12 19:57:31 Client 5 info is not up to dateSent new info to client 5
2024/12/12 19:57:32 Got new message from client 5:
2024/12/12 19:57:33 Got new message from client 5:
2024/12/12 19:57:33 Client 5 info is not up to date
2024/12/12 19:57:33 Sent new info to client 5
2024/12/12 19:57:34 Got new message from client 5:
2024/12/12 19:57:34 Client 5 info is not up to dateSent new info to client 5
2024/12/12 19:57:35 Got new message from client 5:
2024/12/12 19:57:36 Got new message from client 5:
2024/12/12 19:57:36 Sent new info to client 5
2024/12/12 19:57:37 Got new message from client 5:
2024/12/12 19:57:37 Sent new info to client 5
2024/12/12 19:57:38 Got new message from client 5:
2024/12/12 19:57:38 Actual info already on client 5
2024/12/12 19:57:39 Got new message from client 5:
2024/12/12 19:57:39 Sent new info to client 5
2024/12/12 19:57:40 Got new message from client 5:
2024/12/12 19:57:40 Sent new info to client 5
2024/12/12 19:57:41 Got new message from client 5:
2024/12/12 19:57:41 Actual info already on client 5
2024/12/12 19:57:42 Got new message from client 5:
2024/12/12 19:57:42 Sent new info to client 5
2024/12/12 19:57:42 Connection with client 5 closed
2024/12/12 20:00:42 Socket created
2024/12/12 20:00:49 New thread created for socket 5
2024/12/12 20:00:55 Got new message from client 5
2024/12/12 20:00:55 Sent new info to client
2024/12/12 20:00:58 Got new message from client 5
2024/12/12 20:00:58 Sent new info to client
2024/12/12 20:01:00 Got new message from client 5
2024/12/12 20:01:03 Got new message from client 5
2024/12/12 20:01:03 Sent new info to client
2024/12/12 20:01:04 Got new message from client 5
2024/12/12 20:01:04 Sent new info to client
2024/12/12 20:01:05 Got new message from client 5
2024/12/12 20:01:06 Got new message from client 5
2024/12/12 20:01:07 Got new message from client 5
2024/12/12 20:01:07 Sent new info to client
2024/12/12 20:01:08 Got new message from client 5
2024/12/12 20:01:08 Actual info already on client
2024/12/12 20:01:09 Got new message from client 5
2024/12/12 20:01:09 Sent new info to client
2024/12/12 20:01:10 Got new message from client 5
2024/12/12 20:01:10 Sent new info to client
2024/12/12 20:01:11 Got new message from client 5
2024/12/12 20:01:11 Actual info already on client
2024/12/12 20:01:12 Got new message from client 5
2024/12/12 20:01:13 Got new message from client 5
2024/12/12 20:01:14 Got new message from client 5
2024/12/12 20:01:14 Actual info already on client
2024/12/12 20:01:21 Connection with client 5 closed
2024/12/12 20:14:22 Socket created
2024/12/12 20:14:31 New thread created for socket 4
2024/12/12 20:14:49 Got new message from client 4
2024/12/12 20:14:54 Connection with client 4 closed
2024/12/12 20:22:52 New thread created for socket 4

View File

@ -1,14 +1,27 @@
2024/12/14 02:47:49 Socket created
2024/12/14 02:47:58 Socket created
2024/12/14 02:48:44 New thread created for socket 4
2024/12/14 02:48:55 Got new message from client 4
2024/12/14 02:49:26 Got new message from client 4
2024/12/14 02:49:26 Sent new info to client
2024/12/14 02:50:05 Socket created
2024/12/14 02:50:08 New thread created for socket 4
2024/12/14 02:50:17 Got new message from client 4
2024/12/14 02:50:17 uwu
2024/12/14 02:50:27 Got new message from client 4
2024/12/14 02:51:36 Connection with client 4 closed
2024/12/14 02:51:56 Socket created
2024/12/14 02:51:58 Socket created
2024/12/14 02:58:09 Socket created
2024/12/14 02:59:00 New thread created for socket 4
2024/12/14 02:59:09 Got new message from client 4
2024/12/14 02:59:09 last_error
2024/12/14 02:59:49 Got new message from client 4
2024/12/14 03:00:35 Connection with client 4 closed
2024/12/14 03:02:02 New thread created for socket 5
2024/12/14 03:02:12 Got new message from client 5
2024/12/14 03:02:12 cursor_position
2024/12/14 03:02:15 Got new message from client 5
2024/12/14 03:02:15 cursor_position
2024/12/14 03:02:18 Got new message from client 5
2024/12/14 03:02:21 Got new message from client 5
2024/12/14 03:02:21 Sent new info to client
2024/12/14 03:02:24 Got new message from client 5
2024/12/14 03:02:24 cursor_position
2024/12/14 03:02:24 Sent new info to client
2024/12/14 03:02:27 Got new message from client 5
2024/12/14 03:02:27 cursor_position
2024/12/14 03:02:30 Got new message from client 5
2024/12/14 03:02:30 cursor_position
2024/12/14 03:02:33 Got new message from client 5
2024/12/14 03:02:33 cursor_position
2024/12/14 03:02:33 Sent new info to client
2024/12/14 03:02:36 Got new message from client 5
2024/12/14 03:02:36 cursor_position
2024/12/14 03:02:38 Connection with client 5 closed

View File

@ -212,7 +212,8 @@ void* handle_connection(void* arg) {
while (true) {
// Recieve message from client
char buffer[128];
ssize_t bytes_recieved = recv(client_socket, buffer, sizeof(buffer), 0);
ssize_t bytes_recieved = recv(client_socket, buffer, sizeof(buffer) - 1, 0);
buffer[bytes_recieved] = '\0';
// If connection closed
if (bytes_recieved == 0) {

Binary file not shown.

View File

@ -212,7 +212,8 @@ void* handle_connection(void* arg) {
while (true) {
// Recieve message from client
char buffer[128];
ssize_t bytes_recieved = recv(client_socket, buffer, sizeof(buffer), 0);
ssize_t bytes_recieved = recv(client_socket, buffer, sizeof(buffer) - 1, 0);
buffer[bytes_recieved] = '\0';
// If connection closed
if (bytes_recieved == 0) {