15 #include <ecl/config/ecl.hpp>    20 #include "../../include/ecl/io/socketpair.hpp"    26 #define DATA1 "In Xanadu, did Kublai Khan . . ."    27 #define DATA2 "A stately pleasure dome decree . . ."    40 DWORD WINAPI f(LPVOID args) {
    45                         std::cerr << 
"Failed to write to the threaded socket." << std::endl;
    47                 if ( ::recv(
socket_pair[1], reinterpret_cast<char*>(buf), 1024, 0) < 0 ) {
    48                         std::cerr << 
"Failed to read from the threaded socket." << std::endl;
    50                         std::cout << buf << std::endl;
    60         return WSAGetLastError();
    69 int main(
int argc, 
char **argv) {
    73                 std::cout << error.
what() << std::endl;
    83                 std::cout << error.
what() << std::endl;
    84                 std::cout << 
"SocketPair Error: " << 
socket_error() << std::endl;
    91         HANDLE thread_handle = CreateThread(
   101                 if ( ::recv(
socket_pair[0], reinterpret_cast<char*>(buf), 1024, 0) < 0 ) {
   102                         std::cerr << 
"Failed to read from the main socket." << std::endl;
   104                         std::cout << buf << std::endl;
   107                         std::cerr << 
"Failed to write to the main socket." << std::endl;
   113         if ((child = fork()) == -1) {
   114                 std::cerr << 
"Failed to fork." << std::endl;
   119                                 std::cerr << 
"Failed to read from the socket." << std::endl;
   121                                 std::cout << buf << std::endl;
   124                                 std::cerr << 
"Failed to write to the socket." << std::endl;
   132                                 std::cerr << 
"Failed to write to the socket." << std::endl;
   135                                 std::cerr << 
"Failed to read from the socket." << std::endl;
   137                                 std::cout << buf << std::endl;
 virtual ErrorFlag flag() const 
virtual const char * what() const 
ecl_io_PUBLIC SocketError socketpair(socket_descriptor socket_fd_pair[2], const bool non_blocking=false)
Creates a socket pair internal to the current process. 
int main(int argc, char **argv)
int socket_descriptor
Cross-platform typedef for a socket file descriptor. 
ecl_io_PUBLIC SocketError init_sockets()
Initialise the socket subsystem. 
ecl::socket_descriptor socket_pair[2]
ecl_io_PUBLIC SocketError close_socket(const socket_descriptor &sock)
Close a socket. 
Extends the generic error handler with socket specific error strings.