Skip to content

Commit 1a168ba

Browse files
Update ds3 example
1 parent 655432e commit 1a168ba

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

Discussion/ds3-echoserver/client.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111

1212
#include "network_utils.h"
1313

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+
*/
2526

2627
const unsigned int MESSAGE_INTERVAL_S = 2;
2728

Discussion/ds3-echoserver/server.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <arpa/inet.h> //close
2-
#include <array> // std::array
32
#include <cstdio>
43
#include <cstdlib>
54
#include <errno.h>
@@ -27,6 +26,9 @@
2726
* And then running the client with the following command:
2827
* $ ./server
2928
* 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
3032
*/
3133

3234
int create_server_listen_socket(int port) {
@@ -88,9 +90,8 @@ void serve(int listen_sockfd) {
8890
// If we're here, that means there is activity on one of the sockets!
8991
// select() will block until the timeout passes or activity occurs
9092

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!
9495
if (FD_ISSET(listen_sockfd, &readfds)) {
9596
sockaddr_in addr{};
9697
socklen_t addrlen = sizeof(addr);

0 commit comments

Comments
 (0)