Add the keep alive option for testing.
This commit is contained in:
parent
439d6b1bf7
commit
f815889d15
1 changed files with 3 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ int main(int argc, char **argv)
|
||||||
int socketEchoFD;
|
int socketEchoFD;
|
||||||
int clientEchoFD;
|
int clientEchoFD;
|
||||||
int reuseAddrOpt = 1;
|
int reuseAddrOpt = 1;
|
||||||
|
int keepAliveOpt = 1;
|
||||||
char message[BUFFER_SIZE];
|
char message[BUFFER_SIZE];
|
||||||
int messageBytes;
|
int messageBytes;
|
||||||
struct sockaddr_in serverAddr;
|
struct sockaddr_in serverAddr;
|
||||||
|
|
@ -34,7 +35,8 @@ int main(int argc, char **argv)
|
||||||
// use the setsockopt function to make the socket accept different configurations
|
// use the setsockopt function to make the socket accept different configurations
|
||||||
// allow for the reuse of the address/bind.
|
// allow for the reuse of the address/bind.
|
||||||
setsockopt(socketEchoFD, SOL_SOCKET, SO_REUSEADDR, &reuseAddrOpt, sizeof(reuseAddrOpt));
|
setsockopt(socketEchoFD, SOL_SOCKET, SO_REUSEADDR, &reuseAddrOpt, sizeof(reuseAddrOpt));
|
||||||
// also need to set the socket to non-blocking using setsockopt?
|
// also need to set the socket to keepalive using setsockopt
|
||||||
|
setsockopt(socketEchoFD, SOL_SOCKET, SO_KEEPALIVE, &keepAliveOpt, sizeof(keepAliveOpt));
|
||||||
// CODE HERE
|
// CODE HERE
|
||||||
// bind the TCP socket to port 8888 / ECHOPORT
|
// bind the TCP socket to port 8888 / ECHOPORT
|
||||||
serverAddr.sin_family = AF_INET;
|
serverAddr.sin_family = AF_INET;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue