mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
EchoServer: Port to LibMain
This commit is contained in:
parent
289cf8d7ef
commit
98c8eca70c
2 changed files with 7 additions and 15 deletions
|
@ -9,4 +9,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_bin(EchoServer)
|
serenity_bin(EchoServer)
|
||||||
target_link_libraries(EchoServer LibCore)
|
target_link_libraries(EchoServer LibCore LibMain)
|
||||||
|
|
|
@ -9,28 +9,20 @@
|
||||||
#include <AK/IPv4Address.h>
|
#include <AK/IPv4Address.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
#include <LibCore/TCPServer.h>
|
#include <LibCore/TCPServer.h>
|
||||||
#include <stdio.h>
|
#include <LibMain/Main.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio unix inet id accept", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio unix inet id accept", nullptr));
|
||||||
perror("pledge");
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil(nullptr, nullptr) < 0) {
|
|
||||||
perror("unveil");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int port = 7;
|
int port = 7;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_option(port, "Port to listen on", "port", 'p', "port");
|
args_parser.add_option(port, "Port to listen on", "port", 'p', "port");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
if ((u16)port != port) {
|
if ((u16)port != port) {
|
||||||
warnln("Invalid port number: {}", port);
|
warnln("Invalid port number: {}", port);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue