Commit 1a168ba 1 parent 655432e commit 1a168ba Copy full SHA for 1a168ba
File tree 2 files changed +17
-15
lines changed
Discussion/ds3-echoserver
2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 11
11
12
12
#include " network_utils.h"
13
13
14
- /*
15
- * A client that sends a given message to the server every MESSAGE_INTERVAL_S seconds.
16
- * You can run the client by running the standard CMake build process:
17
- * $ mkdir build
18
- * $ cd build
19
- * $ cmake ..
20
- * $ make
21
- * And then running the client with the following command:
22
- * $ ./client --m "Hello from Client A"
23
- * You can also specify the hostname and port; please see the help message for more details.
24
- */
14
+ /*
15
+ * A client that sends a given message to the server every MESSAGE_INTERVAL_S
16
+ * seconds. You can run the client by running the standard CMake build process:
17
+ * $ mkdir build
18
+ * $ cd build
19
+ * $ cmake ..
20
+ * $ make
21
+ * And then running the client with the following command:
22
+ * $ ./client --m "Hello from Client A"
23
+ * You can also specify the hostname and port; please see the help message for
24
+ * more details.
25
+ */
25
26
26
27
const unsigned int MESSAGE_INTERVAL_S = 2 ;
27
28
Original file line number Diff line number Diff line change 1
1
#include < arpa/inet.h> // close
2
- #include < array> // std::array
3
2
#include < cstdio>
4
3
#include < cstdlib>
5
4
#include < errno.h>
27
26
* And then running the client with the following command:
28
27
* $ ./server
29
28
* You can also specify the port; please see the help message for more details.
29
+ *
30
+ * Please consult documentation for select() here:
31
+ * https://man7.org/linux/man-pages/man2/select.2.html
30
32
*/
31
33
32
34
int create_server_listen_socket (int port) {
@@ -88,9 +90,8 @@ void serve(int listen_sockfd) {
88
90
// If we're here, that means there is activity on one of the sockets!
89
91
// select() will block until the timeout passes or activity occurs
90
92
91
- // (3) Check for activity on the listen socket
92
- // Activity on the listen socket means a new client is trying to
93
- // connect!
93
+ // (3) Check for activity on the listen socket -- this indicates that
94
+ // a new client is trying to connect!
94
95
if (FD_ISSET (listen_sockfd, &readfds)) {
95
96
sockaddr_in addr{};
96
97
socklen_t addrlen = sizeof (addr);
You can’t perform that action at this time.
0 commit comments