Created
March 13, 2019 08:40
-
-
Save ayende/7fbbb32219ee1d4860bb8f2e8b9d724b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample showing that we need a way to handle the server not responding to some of the request | |
// separately from the overall time of the request | |
var server = new TcpListener(IPAddress.Any, 888); | |
server.Start(); | |
server.AcceptTcpClientAsync().ContinueWith(x => | |
{ | |
var s = x.Result.GetStream(); | |
s.WriteByte((byte)'H'); | |
while (true) | |
{ | |
s.ReadByte(); | |
} | |
}); | |
var client = new HttpClient(new SocketsHttpHandler | |
{ | |
ResponseDrainTimeout = TimeSpan.FromSeconds(1) | |
}) | |
{ | |
Timeout = TimeSpan.FromSeconds(15), | |
}; | |
var a = client.GetAsync("http://127.0.0.1:888/test").Result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment