Last active
March 13, 2016 20:25
-
-
Save lukasz-pyrzyk/a12d487972181b20aba5 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
TcpListener listener = new TcpListener(IPAddress.Any, 55); | |
listener.Start(); | |
TcpClient client = await listener.AcceptTcpClientAsync(); | |
byte[] request; | |
using (NetworkStream ns = client.GetStream()) | |
{ | |
using (MemoryStream ms = new MemoryStream()) | |
{ | |
int i; | |
int bufferSize = 1024 * 2; | |
byte[] buffer = new byte[bufferSize]; | |
while ((i = ns.Read(buffer, 0, buffer.Length)) != 0) | |
{ | |
await ms.WriteAsync(buffer, 0, i); | |
buffer = new Byte[bufferSize]; | |
} | |
request = ms.ToArray(); | |
} | |
} | |
ProcessClientRequest(request); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment