]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - tools/purge/socket.cc
SourceFormat Enforcement
[thirdparty/squid.git] / tools / purge / socket.cc
index 033ffe7adb4b2b8ad9efcce01c6142c1529d5bcd..a2fc2d93e19df6ca937520e74ca3d5e99cbbdd9c 100644 (file)
@@ -1,6 +1,11 @@
-//
-// $Id$
-//
+/*
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 // Author:  Jens-S. V?ckler <voeckler@rvs.uni-hannover.de>
 //
 // File:    socket.hh
 // Revision 1.1  1998/08/13 21:52:55  voeckler
 // Initial revision
 //
-//
-#if defined(__GNUC__) || defined(__GNUG__)
-#pragma implementation
-#endif
 
+#include "squid.h"
 #include "socket.hh"
+
+#include <cerrno>
+#include <cstring>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
 
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "convert.hh"
 
-static const char* RCS_ID =
-    "$Id$";
-
 int
 setSocketBuffers( int sockfd, int size )
 // purpose: set socket buffers for both directions to the specified size
@@ -95,7 +94,7 @@ getSocketNoDelay( int sockfd )
 //         -1, if an error occurred (e.g. datagram socket)
 {
     int delay = 0;
-    SOCKLEN len = sizeof(delay);
+    socklen_t len = sizeof(delay);
     if ( getsockopt( sockfd, IPPROTO_TCP, TCP_NODELAY,
                      (char*) &delay, &len ) == -1 ) {
         perror( "# getsockopt( TCP_NODELAY ) failed" );
@@ -105,7 +104,7 @@ getSocketNoDelay( int sockfd )
 }
 
 int
-setSocketNoDelay( int sockfd, bool nodelay )
+setSocketNoDelay( int sockfd, bool)
 // purpose: get state of the TCP_NODELAY of the socket
 // paramtr: sockfd (IN): socket descriptor
 //          nodelay (IN): true, if TCP_NODELAY is to be set, false otherwise.
@@ -121,7 +120,6 @@ setSocketNoDelay( int sockfd, bool nodelay )
         return 0;
 }
 
-
 int
 commonCode( int& sockfd, bool nodelay, int sendBufferSize, int recvBufferSize )
 // purpose: common code in server sockets and client sockets
@@ -224,9 +222,9 @@ serverSocket( struct in_addr host, unsigned short port,
     }
 
     if ( reuse ) {
-        int reuse = 1;
+        int opt = 1;
         if ( setsockopt( sockfd, SOL_SOCKET, SO_REUSEADDR,
-                         (char*) &reuse, sizeof(int) ) == -1) {
+                         (char*) &opt, sizeof(int) ) == -1) {
             perror( "setsockopt( SO_REUSEADDR )" );
             close( sockfd );
             return -1;
@@ -257,3 +255,4 @@ serverSocket( struct in_addr host, unsigned short port,
 
     return sockfd;
 }
+