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












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Help needed with link errors (serversocket)
Re: Help needed with link errors (serversocket) [message #48514 is a reply to message #48510] Wed, 12 July 2017 11:43 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1094
Registered: August 2007
Senior Contributor
Hello imos, and welcome!

Web package is depreceated. AFAIK, it is kept for historical reasons.
You can use TcpSocket for socket operations.
There is a client/server example in Examples section:
Server: http://www.ultimatepp.org/reference$SocketServer$en-us.html


#include <Core/Core.h>

 

using namespace Upp;

 

CONSOLE_APP_MAIN

{

    TcpSocket server;

    if(!server.Listen(3214, 5)) {

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

        SetExitCode(1);

        return;

    }

    Cout() << "Waiting for requests..\n";

    for(;;) {

        TcpSocket s;

        if(s.Accept(server)) {

            String w = s.GetLine();

            Cout() << "Request: " << w << " from: " << s.GetPeerAddr() << '\n';

            if(w == "time")

                s.Put(AsString(GetSysTime()));

            else

                s.Put(AsString(3 * atoi(~w)));

            s.Put("\n");

        }

    }

}




Client: http://www.ultimatepp.org/reference$SocketClient$en-us.html
#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';

}



Best regards,
Oblivion


[Updated on: Wed, 12 July 2017 11:46]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Choosing the best way to go full UNICODE
Next Topic: SFTP or full SSH2 support for U++?
Goto Forum:
  


Current Time: Wed May 15 17:59:13 CEST 2024

Total time taken to generate the page: 0.02088 seconds