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.
| Tags | Networking Communications |
|---|---|
| Licenses | GPL |
| Operating Systems | Windows POSIX Linux Solaris Mac OS X |
| Implementation | C++ |
Recent releases


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.


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.


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


Release Notes: This release adds CGI support for HttpRequest / HttpdForm. It adds JSON support (parse, use, and generate). There are some small bugfixes.


Release Notes: Win32 problems introduced in 2.3.9.2 were fixed. Multithread support was added in sockethandler. Build problems in mingw/cygwin were fixed.
Recent comments
04 Aug 2011 05:04
Hi,
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='"2.3.9.6"' -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
B.Regards
08 Jun 2011 21:53
Why not use a public svn/git repository?
07 Oct 2010 21:41
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;
}
}
+#endif
}
@@ -1086,8 +1088,11 @@
if (p -> CloseAndDelete() )
{
TcpSocket *tcp = dynamic_cast(p);
- if (p -> Lost() && !(tcp && tcp -> Reconnect()))
- {
+ if (p -> Lost()
+#ifdef ENABLE_RECONNECT
+ && !(tcp && tcp -> Reconnect())
+#endif
+ ) {
// remove instance when Lost, if not reconnect flag is set
DeleteSocket(p);
}
07 Oct 2010 18:56
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='"2.3.9.3"' -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
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.