-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
30 lines (23 loc) · 818 Bytes
/
Program.cs
File metadata and controls
30 lines (23 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace ScriptCs.Net.ConsoleApp
{
using System;
class Program
{
static void Main(string[] args)
{
var net = (Net)new NetScriptPack().GetContext();
var server = net.CreateServer(socket =>
{
Console.WriteLine("New connection");
socket.On(
data: data => Console.WriteLine(data.AsString()),
close: () => Console.WriteLine("Connection closed"),
error: e => Console.WriteLine("Error {0}", e.Message));
});
Console.WriteLine("Listening at 127.0.0.1:8080");
server.Listen(8080, "127.0.0.1").Wait();
Console.WriteLine("Closing server");
server.Close();
}
}
}