mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 06:05:58 -06:00
* Core: UnixSocket (AF_UNIX) implementation Core/UnixSocket: GetPeerPid refactored reference/UnixSocketClient: Use default socket type for connection reference/UnixSocketServer: Use default socket type for listen Core: UnixSocket API docs & cleanup Core: UnixSocket friend declaration guarded using ifdefs. * Core: UnixSocket, GetPeerPid() refactored, docs updated * Core: TcpSocket renamed as Socket and added unix domain socket support. Cleanup Updated API docs. * Core: UnixSocket entry removed from API docs. * Core: Socket/SocketWaitEvent API docs cosmetics. * Core: Socket cosmetics
28 lines
576 B
C++
28 lines
576 B
C++
#include <Core/Core.h>
|
|
|
|
using namespace Upp;
|
|
|
|
// Start reference/UnixSocketServer before starting this program
|
|
|
|
CONSOLE_APP_MAIN
|
|
{
|
|
#ifdef PLATFORM_POSIX
|
|
auto Request = [](const String& r)
|
|
{
|
|
Socket s;
|
|
if(!s.ConnectFileSystem("/tmp/upp-unixsocket.sock")) {
|
|
Cout() << "Unable to connect to server!\n";
|
|
SetExitCode(1);
|
|
return String();
|
|
}
|
|
s.Put(r + '\n');
|
|
return s.GetLine();
|
|
};
|
|
|
|
Cout() << Request("time") << '\n';
|
|
Cout() << Request("33") << '\n';
|
|
#else
|
|
Cout() << "This example requires a POSIX compliant operating system...\r\n"
|
|
SetExitCode(1);
|
|
#endif
|
|
}
|