From 2b3feb19c6771d616641bc9554be0ad3e4552c2b Mon Sep 17 00:00:00 2001 From: EvansSune Date: Mon, 2 Mar 2026 10:47:59 +0800 Subject: [PATCH] Debug The third argument (optname) of setsockopt expects a specific option macro (e.g., the value of SO_REUSEADDR is usually 2), and the intended purpose here is to iterate through the opts container. --- src/TCPServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TCPServer.cpp b/src/TCPServer.cpp index e6c8588..50f25d0 100644 --- a/src/TCPServer.cpp +++ b/src/TCPServer.cpp @@ -63,7 +63,7 @@ int TCPServer::setup(int port, vector opts) memset(&serverAddress,0,sizeof(serverAddress)); for(unsigned int i = 0; i < opts.size(); i++) { - if( (setsockopt(sockfd, SOL_SOCKET, opts.size(), (char *)&opt, sizeof(opt))) < 0 ) { + if( (setsockopt(sockfd, SOL_SOCKET, opts[i], (char *)&opt, sizeof(opt))) < 0 ) { cerr << "Errore setsockopt" << endl; return -1; }