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


Changes: Initialization problems with OpenSSL and Win32 were fixed. A default interface for multicast was added. A crashing problem with getnameinfo on Mac OS X was fixed.


Changes: Some .cpp files were missing namespace declarations and have been fixed. Some includes for IPv6 were missing and have been fixed. Operators in the StreamWriter class were modified to work on 64-bit as well as 32-bit systems.


Changes: A deadlock in SSLInitializer that was introduced in 2.3.2 was fixed. A check was added for when select() returns -1, indicating that one of the file descriptors has gone bad. The check rebuilds the fd_set used by select(). A bug was fixed in HttpGetSocket: one of the constructors had no support in HttpClientSocket. Bad #include directives in Utility were corrected.


Changes: A thread-safe list of the SSL initializer, SSL contexts, and OpenSSL error text retrieval. An interface for the Mutex class adds the ability for others to implement the mutex functionality using other approaches. The FromUtf8 method has been moved from XmlNode to Utility.


Changes: The Remove() method in SocketHandler was changed from private to protected. Utility::Stack was added, which returns a stack walk (currently in Linux only). The $(DESTDIR) variable was added in the Makefile for more flexible installation. The timeout value is now reset before OnTimeout() is called, making it possible to set a new timeout value in the OnTimeout() method.
A tool that collects configuration data on Unix/Linux/BSD systems.
- All comments
Recent commentsRe: Problem running a program linked with V2.1.7 & V2.3
In fact the problem went away as soon as I compiled the libraries using STLPort.
> I've been using V2.1 and things have
> been working fine. I have recently
> found a problem with the V2.1 and in
> looking at the code it appears that V2.3
> has fixed the issue.
>
> When I attempt to run a program that now
> includes the V2.3 it aborts when
> running. If I switch back to V2.1 it
> runs with the exception noted above.
>
> In order to get my code to compile with
> the V2.3 it was necessary to define
> _WIN32_WINNT=0x0501. This appears to be
> due to the change in socket_include.h
> where winsock2.h is now included instead
> of winsock.h. This change is in
> V2.1.7.
>
> Did anyone else have issues when
> upgrading to the new version?
>
> Can I get a copy of the libraries 2.1.1
> - 2.1.6?
>
>
Problem running a program linked with V2.1.7 & V2.3
I've been using V2.1 and things have been working fine. I have recently found a problem with the V2.1 and in looking at the code it appears that V2.3 has fixed the issue.
When I attempt to run a program that now includes the V2.3 it aborts when running. If I switch back to V2.1 it runs with the exception noted above.
In order to get my code to compile with the V2.3 it was necessary to define _WIN32_WINNT=0x0501. This appears to be due to the change in socket_include.h where winsock2.h is now included instead of winsock.h. This change is in V2.1.7.
Did anyone else have issues when upgrading to the new version?
Can I get a copy of the libraries 2.1.1 - 2.1.6?
Compilation error
...
g++ -Wall -g -MD -D_VERSION='"2.1.6"' -O2 -DLINUX -c -o Sockets-config.o Sockets-config.cpp
g++ -o Sockets-config Sockets-config.o
/usr/lib/gcc/i586-suse-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0xc): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/i586-suse-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0x11): undefined reference to `__libc_csu_init'
collect2: ld returned 1 exit status
make: *** [Sockets-config] Error 1
danny:~/installs/Sockets-2.1.6 #
This also happened with 2.1.5. Version 2.1.4 was OK
Problems in compiling test program in DevC++
Hi,
I am a newbie in C++ programming. I downloaded the zip of source code and tried to compile the test.cpp in DevC++ environment.I have installed OpenSSL but still I am getting following errors. Please help.
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Jaideep Padhye\Desktop\Sockets-2.1\Sockets-2.1\DevCpp\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\Jaideep Padhye\Desktop\Sockets-2.1\Sockets-2.1\DevCpp\Makefile.win" all
g++.exe -c ../sockets_test.cpp -o bin/sockets_test.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I".." -DHAVE_OPENSSL
g++.exe bin/sockets_test.o -o "..\..\bin\Test.exe" -L"C:/Dev-Cpp/lib" -L"C:/OpenSSL/lib/MinGW" ../../lib/Sockets.a ../../../../DevCpp/lib/libwsock32.a ../../../../OpenSSL/lib/MinGW/ssleay32.a ../../../../OpenSSL/lib/MinGW/libeay32.a
g++.exe: ../../../../DevCpp/lib/libwsock32.a: No such file or directory
g++.exe: ../../../../OpenSSL/lib/MinGW/ssleay32.a: No such file or directory
g++.exe: ../../../../OpenSSL/lib/MinGW/libeay32.a: No such file or directory
make.exe: *** [../../bin/Test.exe] Error 1
Execution terminated
make for Mac OS X
Hi, I'am using Mac OS X 10.2.8 I've recently installed the Operative System.
When I try make Sockets-2.1, I get the following error:
g++ -Wall -g -I. -MD -D_VERSION='"2.1"' -O2 -DMACOSX -DSOCKETS_NAMESPACE=sockets -D_DEBUG -c -o Socket.o Socket.cpp
In file included from Socket.cpp:45:
SocketAddress.h:29: error: parse error before `(' token
SocketAddress.h:29: warning: ISO C++ forbids declaration of `<invalid operator>
' with no type
SocketAddress.h:29: error: `<invalid operator>' declared as a `virtual' field
Socket.cpp: In member function `virtual void sockets::Socket::OnException()':
Socket.cpp:171: error: `socklen_t' undeclared (first use this function)
Socket.cpp:171: error: (Each undeclared identifier is reported only once for
each function it appears in.)
Socket.cpp:171: error: parse error before `=' token
Socket.cpp:175: error: `errlen' undeclared (first use this function)
Socket.cpp: In member function `virtual bool sockets::Socket::CheckConnect()':
Socket.cpp:195: error: parse error before `=' token
make: *** [Socket.o] Error 1
The project compiles in Windows XP without problems.
What I'm doing wrong? I'm newbye in Mac architecture.
I'll appreciate your help.
Salutations.