aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/Client.hx14
-rw-r--r--examples/Server.hx30
2 files changed, 22 insertions, 22 deletions
diff --git a/examples/Client.hx b/examples/Client.hx
index 675fe94..4ee85c5 100644
--- a/examples/Client.hx
+++ b/examples/Client.hx
@@ -4,16 +4,16 @@ import haxe.io.Bytes;
import unix.UnixSocket;
class Client {
- static function main() {
- var server = new UnixSocket("haxe.sock");
- server.init();
+ static function main() {
+ var server = new UnixSocket("haxe.sock");
+ server.init();
server.connect();
server.writeBytes(Bytes.ofString("Ping"));
- var receivedData = server.readBytes("Pong".length);
- trace(receivedData);
+ var receivedData = server.readBytes("Pong".length);
+ trace(receivedData);
- server.close();
- }
+ server.close();
+ }
}
diff --git a/examples/Server.hx b/examples/Server.hx
index 87e00a4..a0a65c6 100644
--- a/examples/Server.hx
+++ b/examples/Server.hx
@@ -5,25 +5,25 @@ import sys.FileSystem;
import unix.UnixSocket;
class Server {
- static function main() {
- var server = new UnixSocket("haxe.sock");
+ static function main() {
+ var server = new UnixSocket("haxe.sock");
- server.init();
- server.bind();
- server.listen(5);
+ server.init();
+ server.bind();
+ server.listen(5);
while (true) {
trace('Waiting for clients to connect...');
- var client = server.accept();
- trace('Accepted connection from client with fd ${client.fileDescriptor}');
- var receivedData = client.readBytes("Ping".length).toString();
- trace('$receivedData');
- client.writeBytes(Bytes.ofString("Pong"));
- client.close();
- }
+ var client = server.accept();
+ trace('Accepted connection from client with fd ${client.fileDescriptor}');
+ var receivedData = client.readBytes("Ping".length).toString();
+ trace('$receivedData');
+ client.writeBytes(Bytes.ofString("Pong"));
+ client.close();
+ }
- if (FileSystem.exists("haxe.sock")) {
- FileSystem.deleteFile("haxe.sock");
+ if (FileSystem.exists("haxe.sock")) {
+ FileSystem.deleteFile("haxe.sock");
}
- }
+ }
}