HttpServerBoxed 0.0.11 alpha
A simple http server for C# and .NET
Loading...
Searching...
No Matches
HSB.Custom Class Reference

Public Member Functions

void Run ()
 

Detailed Description

Definition at line 9 of file Custom.cs.

Constructor & Destructor Documentation

◆ Custom()

HSB.Custom.Custom ( )

Definition at line 19 of file Custom.cs.

20 {
21 Console.WriteLine("Hello from HSB");
22 c.SetTLSVersion(TLSVersion.TLS_1_2);
23 c.RunAsync(false, 700);
24 //c.setCipherSuites("TLS_AES_256_GCM_SHA384 TLS_CHACHA20_POLY1305_SHA256 TLS_AES_128_GCM_SHA256 TLS_AES_128_CCM_8_SHA256 TLS_AES_128_CCM_SHA256");
25
26 endPoint = new(address, 443);
27
28
29 listener = new(
30 address.AddressFamily,
31 SocketType.Stream,
32 ProtocolType.Tcp
33 );
34
35 listener.Bind(endPoint);
36 listener.Listen(100);
37 }

Member Function Documentation

◆ Run()

void HSB.Custom.Run ( )

Definition at line 39 of file Custom.cs.

40 {
41 while (true)
42 {
43 Socket newSocket = listener.Accept();
44 int received = newSocket.Receive(buffer);
45 if (received > 0 && buffer[0] == 0x16) //parse client hello
46 {
47 new CustomTLS(newSocket).Parse(buffer);
48 }
49 else
50 {
51 //Plain HTTP methods are NOT allowed
52 string reply = "HTTP/1.1 405 Method Not Allowed\r\n" +
53 "Content-Type: text/html\r\n" +
54 "Content-Length: 0\r\n" +
55 "Connection: close\r\n" +
56 "\r\n";
57
58 newSocket.Send(Encoding.UTF8.GetBytes(reply));
59 newSocket.Close();
60 }
61
62 Thread.Sleep(125);
63 }
64
65 }

The documentation for this class was generated from the following file: