Answer the question
In order to leave comments, you need to log in
How do the server and client (C++, Linux) interact with each other?
I began to write code for the server and client in C ++ on Linux using Berkeley sockets (according to the video lesson).
Separately, I more or less figured out the server and client code, but did not understand what to do after running the server and client applications, how to send and receive requests from the server and client?
Maybe I just entered something wrong, but I was unable to send or receive any data, and I would be very grateful if you check my simple code:
Server: pastebin.com/QwWdf9Mf
Client: pastebin.com/LaLVUq4A
Answer the question
In order to leave comments, you need to log in
There is a problem on the server. On the first iteration, you ask to read 0 bytes, which succeeds. counter is not incremented and you are in an infinite loop.
ssize_t recv(int sockfd, void *buf, size_t len, int flags); len == 0 you always have. buf is also incorrectly specified (with counter = 0 you write after the end of the buffer).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question