Skip to content

Instantly share code, notes, and snippets.

@mushfiqweb
Created April 25, 2017 00:50
Show Gist options
  • Save mushfiqweb/0751e560c936955db14e7c77ece4fcbb to your computer and use it in GitHub Desktop.
Save mushfiqweb/0751e560c936955db14e7c77ece4fcbb to your computer and use it in GitHub Desktop.
Socket socket = tcpClient.Client;
byte[] buffer = new byte[12]; // length of the text "Hello world!"
try
{ // receive data with timeout 10s
MyClass.Receive(socket, buffer, 0, buffer.Length, 10000);
string str = Encoding.UTF8.GetString(buffer, 0, buffer.Length);
}
catch (Exception ex) { /* ... */ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment