Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

SocketClient

 

Example of using client Socket - its counterpart is SocketServer

 

 

SocketClient.cpp

 

#include <Core/Core.h>

 

using namespace Upp;

 

String Request(const String& r)

{

    TcpSocket s;

    if(!s.Connect(CommandLine().GetCount() ? CommandLine()[0] : "127.0.0.1", 3214)) {

        Cout() << "Unable to connect to server!\n";

        SetExitCode(1);

        return Null;

    }

    s.Put(r + '\n');

    return s.GetLine();

}

 

// Start reference/SocketServer before starting this program

 

CONSOLE_APP_MAIN

{

    Cout() << Request("time") << '\n';

    Cout() << Request("33") << '\n';

}

 

 

 

 

Do you want to contribute?