Created
March 5, 2015 09:30
-
-
Save one-harsh/7e8c8702e648a58a64fc 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
using System; | |
using System.Net.Sockets; | |
using System.Text; | |
namespace DummySocketClient | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
using(TcpClient client = new TcpClient("127.0.0.1", 37517)) // Change the IP and port according to your needs. | |
{ | |
client.SendTimeout = 3; | |
using(NetworkStream stream = client.GetStream()) | |
{ | |
byte[] data = new byte[4096]; | |
string response = ""; | |
int bytes = stream.Read(data, 0, data.Length); | |
response = Encoding.ASCII.GetString(data, 0, bytes); | |
Console.WriteLine(response); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment