File tree Expand file tree Collapse file tree 4 files changed +2
-53
lines changed
src/Servers/Kestrel/samples Expand file tree Collapse file tree 4 files changed +2
-53
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,6 @@ public static void Main(string[] args)
29
29
{
30
30
var basePort = context . Configuration . GetValue < int ? > ( "BASE_PORT" ) ?? 5000 ;
31
31
32
- // Run callbacks on the transport thread
33
- options . ApplicationSchedulingMode = SchedulingMode . Inline ;
34
-
35
32
// Http/1.1 endpoint for comparison
36
33
options . Listen ( IPAddress . Any , basePort , listenOptions =>
37
34
{
Original file line number Diff line number Diff line change 10
10
using Microsoft . AspNetCore . Builder ;
11
11
using Microsoft . AspNetCore . Connections ;
12
12
using Microsoft . AspNetCore . Hosting ;
13
- using Microsoft . AspNetCore . Server . Kestrel . Transport . Sockets ;
14
13
15
14
namespace PlaintextApp
16
15
{
@@ -40,52 +39,11 @@ public static async Task Main(string[] args)
40
39
{
41
40
options . Listen ( IPAddress . Loopback , 5001 ) ;
42
41
} )
43
- // .UseLibuv()
44
42
. UseContentRoot ( Directory . GetCurrentDirectory ( ) )
45
43
. UseStartup < Startup > ( )
46
44
. Build ( ) ;
47
45
48
- var hostTask = host . RunAsync ( ) ;
49
- var serverTask = ServerAsync ( new SocketTransportFactory ( ) , 5002 ) ;
50
-
51
- await hostTask ; ;
52
- }
53
-
54
- private static async Task ServerAsync ( IConnectionListenerFactory factory , int port )
55
- {
56
- await using var listener = await factory . BindAsync ( new IPEndPoint ( IPAddress . Loopback , port ) ) ;
57
-
58
- while ( true )
59
- {
60
- var connection = await listener . AcceptAsync ( ) ;
61
-
62
- // Fire and forget so we can handle more than a single connection at a time
63
- _ = HandleConnectionAsync ( connection ) ;
64
-
65
- static async Task HandleConnectionAsync ( ConnectionContext connection )
66
- {
67
- await using ( connection )
68
- {
69
- while ( true )
70
- {
71
- var result = await connection . Transport . Input . ReadAsync ( ) ;
72
- var buffer = result . Buffer ;
73
-
74
- foreach ( var segment in buffer )
75
- {
76
- await connection . Transport . Output . WriteAsync ( segment ) ;
77
- }
78
-
79
- if ( result . IsCompleted )
80
- {
81
- break ;
82
- }
83
-
84
- connection . Transport . Input . AdvanceTo ( buffer . End ) ;
85
- }
86
- }
87
- }
88
- }
46
+ await host . RunAsync ( ) ;
89
47
}
90
48
}
91
49
Original file line number Diff line number Diff line change @@ -95,9 +95,6 @@ public static Task Main(string[] args)
95
95
httpsOptions . SslProtocols = SslProtocols . Tls12 ;
96
96
} ) ;
97
97
98
- // Run callbacks on the transport thread
99
- options . ApplicationSchedulingMode = SchedulingMode . Inline ;
100
-
101
98
options . Listen ( IPAddress . Loopback , basePort , listenOptions =>
102
99
{
103
100
// Uncomment the following to enable Nagle's algorithm for this endpoint.
Original file line number Diff line number Diff line change @@ -51,9 +51,6 @@ public static Task Main(string[] args)
51
51
{
52
52
var basePort = context . Configuration . GetValue < int ? > ( "BASE_PORT" ) ?? 5000 ;
53
53
54
- // Run callbacks on the transport thread
55
- options . ApplicationSchedulingMode = SchedulingMode . Inline ;
56
-
57
54
options . Listen ( IPAddress . Loopback , basePort , listenOptions =>
58
55
{
59
56
// Uncomment the following to enable Nagle's algorithm for this endpoint.
@@ -89,4 +86,4 @@ public static Task Main(string[] args)
89
86
return hostBuilder . Build ( ) . RunAsync ( ) ;
90
87
}
91
88
}
92
- }
89
+ }
You can’t perform that action at this time.
0 commit comments