Tutorial by Examples

This code example creates a TCP client, sends "Hello World" over the socket connection, and then writes the server response to the console before closing the connection. // Declare Variables string host = "stackoverflow.com"; int port = 9999; int timeout = 5000; // Create ...
Downloading a file from the internet is a very common task required by almost every application your likely to build. To accomplish this, you can use the "System.Net.WebClient" class. The simplest use of this, using the "using" pattern, is shown below: using (var webClient = n...
Using async/await in C# applications simplifies multi-threading. This is how you can use async/await in conjunction with a TcpClient. // Declare Variables string host = "stackoverflow.com"; int port = 9999; int timeout = 5000; // Create TCP client and connect // Then get the netstr...
This code example creates a UDP client then sends "Hello World" across the network to the intended recipient. A listener does not have to be active, as UDP Is connectionless and will broadcast the message regardless. Once the message is sent, the clients work is done. byte[] data = Enco...

Page 1 of 1