Projects / C++ Sockets

C++ Sockets

C++ Sockets is a cross-platform C++ wrapper for BSD-style sockets. It implements the TCP, UDP, ICMP, and SCTP transport layer protocols. Implemented application layer protocols are HTTP/HTTPS (using OpenSSL), SMTP (server), and Ajp/1.3 (server). Features include transparent SOCKS4 client support and asynchronous DNS. Included in the library are a number of HTTP client functions such as GET/PUT/POST, and also Web server framework components.

Operating Systems

Recent releases

  •  22 Jun 2013 09:17

    Release Notes: A bug that prevented HttpGetSocket from exiting normally if a zero byte resource was fetched was fixed. Some missing includes were included for newer compilers.

    •  10 Apr 2013 18:02

      Release Notes: Multiple include file problems were fixed on Mac OS X, Win32, and GCC 4.7. Authentication support was added to HTTPSocket and Utility URL parser. clang can now be used with the environment variable 'USE_CLANG=with_clang'. Support for certificate chains in TCP sockets was added. An uninitialized variable bug in UdpSocket was fixed. The extra 'Xml' namespace was removed from libxml2 wrapper classes.

      •  16 Aug 2011 17:42

        Release Notes: Detach threads that never stopped has been fixed. Detaching from OnAccept method now works. Time to launch a detached thread has been reduced.

        •  25 Jul 2011 22:26

          Release Notes: A timing problem has been solved in detached sockets. More configure options have been added. Lost state flags are now retrieved in sockethandler. The AJP client socket has been updated. The JSON parser has been updated.

          •  05 Feb 2011 09:17

            Release Notes: This version fixed missing includes and ambigouos operators and constructors.

            Recent comments

            04 Aug 2011 05:04 Hirogens


            I can't compile.
            under Seven 64Bits/ Cygwin lastest, no support windows.
            (I can compile big lib, Boost, Mysql, Apache etc)
            normally no problem on my installation.

            I have this error. (Compiler GCC 4.3.4)
            compile with "linux-x86-32"

            g++ -Wall -g -I/usr/include/libxml2 -MD -D_VERSION='""' -O2 -DLINUX -c -o Socket.o Socket.cpp
            Socket.cpp: In member function 'bool Socket::IpAddMembership(ip_mreqn&)':
            Socket.cpp:1248: error: invalid application of 'sizeof' to incomplete type 'ip_mreqn'
            Socket.cpp: In member function 'bool Socket::IpDropMembership(ip_mreqn&)':
            Socket.cpp:1282: error: invalid application of 'sizeof' to incomplete type 'ip_mreqn'
            make: *** [Socket.o] Error 1


            08 Jun 2011 21:53 DerekMcGowan

            Why not use a public svn/git repository?

            07 Oct 2010 21:41 wurzelfm

            The following patch allows it to build with DETACH and RECONNECT unconfigured.

            diff --git a/SocketHandler.cpp b/SocketHandler.cpp
            --- a/SocketHandler.cpp
            +++ b/SocketHandler.cpp
            @@ -1001,6 +1001,7 @@
            void SocketHandler::CheckDetach()
            m_b_check_detach = false;
            +#ifdef ENABLE_DETACH
            for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
            Socket *p = it -> second;
            @@ -1016,6 +1017,7 @@
            m_b_check_detach = true;

            @@ -1086,8 +1088,11 @@
            if (p -> CloseAndDelete() )
            TcpSocket *tcp = dynamic_cast<TcpSocket *>(p);
            - if (p -> Lost() && !(tcp && tcp -> Reconnect()))
            - {
            + if (p -> Lost()
            +#ifdef ENABLE_RECONNECT
            + && !(tcp && tcp -> Reconnect())
            + ) {
            // remove instance when Lost, if not reconnect flag is set

            07 Oct 2010 18:56 wurzelfm

            Disabling DETACH or RECONNECT breaks the build in v2.3.9.3:
            I turned off both of these in my config-sockets.h file and when I make:

            mipsisa32-xlr-linux-g++ -Wall -g -I/usr/include/libxml2 -MD -D_VERSION='""' -O2 -DLINUX -fPIC -c -o SocketHandler.o SocketHandler.cpp
            SocketHandler.cpp: In member function `void SocketHandler::CheckDetach()':
            SocketHandler.cpp:1007: error: 'class Socket' has no member named 'IsDetach'
            SocketHandler.cpp:1012: error: 'class Socket' has no member named 'DetachSocket'
            SocketHandler.cpp: In member function `void SocketHandler::CheckClose()':
            SocketHandler.cpp:1089: error: 'class TcpSocket' has no member named 'Reconnect'
            make[1]: *** [SocketHandler.o] Error 1

            16 Jun 2010 09:34 e1212dison

            I use this library in my assignment. It is a chatting program, C++ Sockets as low level, QT as GUI, works well.

            Just curious how robust is this lib.
            I have found another similar library Boost:asio.
            What's the advantage and disadvantage of this C++ Sockets.


            Project Spotlight


            A Fluent OpenStack client API for Java.


            Project Spotlight

            TurnKey TWiki Appliance

            A TWiki appliance that is easy to use and lightweight.