reference: SocketClient and SocketServer changed to use Core:TcpSocket

git-svn-id: svn://ultimatepp.org/upp/trunk@5382 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-09-22 08:12:58 +00:00
parent a0f7972d4b
commit ec179e638b
2 changed files with 49 additions and 47 deletions

View file

@ -1,21 +1,23 @@
#include <Web/Web.h>
using namespace Upp;
String Request(const String& r)
{
Socket s;
if(!ClientSocket(s, CommandLine().GetCount() ? CommandLine()[0] : "127.0.0.1", 3214)) {
Cout() << "Unable to connect to server!\n";
SetExitCode(1);
return Null;
}
s.Write(r + '\n');
return s.ReadUntil('\n');
}
CONSOLE_APP_MAIN
{
Cout() << Request("time") << '\n';
Cout() << Request("33") << '\n';
}
#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';
}