void handle_client(net::tcp_socket::sockhandle handle)
{
    std::cout << "client " <<  handle << std::endl;

    net::tcp_socket session_socket(handle);
    session_socket.send( send_msg, sizeof(send_msg) );

    if( session_socket.peerDisconnected())
        return;

    std::cout << "TCP server sucessfully sent data to the client." << std::endl;

    session_socket.disconnect();
}
int main()
{
	try {

	NET::TCPSocket server_socket;

	// listen locally on the given port
	server_socket.bind( "127.0.0.1", 47777);
	server_socket.listen();

	NET::TCPSocket::Handle handle = server_socket.timedAccept(5000);
	// nobody connected within 5s
	if(!handle) return 1;

	// create a new socket to communicate with the connected client
	// if we do nothing at this point, the connection will be discarded
	NET::TCPSocket session_socket(handle);
	session_socket.send( send_msg, sizeof(send_msg) );

	// client disconnected before he could receive anything
	if( session_socket.peerDisconnected()) return 1;

	std::cout << "TCP server sucessfully sent data to the client." << std::endl;

	// this is optional, we could simply do nothing here
	session_socket.disconnect();

	// if something fails, we get here
	} catch( const NET::SocketException& e)
	{
		std::cerr << e.what() << std::endl;
		return 1;
	}

	return 0;
}