33 lines
703 B
Plaintext
33 lines
703 B
Plaintext
use System.IO.Net, Collection;
|
|
|
|
class DistPrgm {
|
|
function : Main(args : String[]) ~ Nil {
|
|
if(args->Size() = 1) {
|
|
target := args[0];
|
|
port := 8888;
|
|
|
|
if(target->Equals("client")) {
|
|
DoClient(port);
|
|
}
|
|
else if(target->Equals("server")) {
|
|
DoServer(port);
|
|
}
|
|
}
|
|
}
|
|
|
|
function : DoServer(port : Int) ~ Nil {
|
|
server := TCPSocketServer->New(port);
|
|
if(server->Listen(10)) {
|
|
client := server->Accept();
|
|
client->ReadLine()->PrintLine();
|
|
client->Close();
|
|
};
|
|
}
|
|
|
|
function : DoClient(port : Int) ~ Nil {
|
|
server := TCPSocket->New("localhost", port);
|
|
server->WriteString("Hello World!\r\n");
|
|
server->Close();
|
|
}
|
|
}
|