diff --git a/Home.md b/Home.md index c840fb4..6769dd6 100644 --- a/Home.md +++ b/Home.md @@ -1,91 +1 @@ -### Server -```cpp -#include -#include - -using namespace ehs; - -Vector clients; - -void HandleClients() { - for (UInt_64 i = 0; i < clients.Size(); ++i) { - Str_8 data(256); - - UInt_64 received = clients[i]->Receive((Byte *)&data[0], data.Size()); - if (!received) - continue; - - data.Resize(received); - - Console::Write_8(data); - } -} - -int main() -{ - Initialize("Server", "Alpha", {1, 0, 0}); - - TCP server; - server.Initialize(); - server.SetBlocking(false); - server.Bind("", 1234); - Console::Write_8("server started on port 1234"); - server.Listen(); - - while (true) { - TCP *client = server.Accept(); - if (client) { - client->SetBlocking(false); - - clients.Push(client); - - client->SendStr("Successfully connected to server."); - } - - HandleClients(); - } - - Uninitialize(); - - return 0; -} -``` - -### Client -```cpp -#include -#include -#include - -using namespace ehs; - -int main() { - Initialize("Client", "Alpha", {1, 0, 0}); - - TCP client(IP::V4); - client.Initialize(); - client.SetBlocking(false); - client.Connect("127.0.0.1", 1234); - - while (true) { - Str_8 data(256); - - UInt_64 received = client.Receive((Byte*)&data[0], data.Size()); - - if (received) - { - data.Resize(received); - - Console::Write_8(data); - } - - Str_8 msg = Console::Read_8(); - - client.SendStr(msg); - } - - Uninitialize(); - - return 0; -} -``` \ No newline at end of file +Hello world! \ No newline at end of file