Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Net.Sockets;
- using System.Text;
- class test
- {
- public static void Main(String[] args)
- {
- string hostName = "india.colorado.edu";
- int hostPort = 13;
- IPAddress ip = Dns.GetHostAddresses(hostName)[0];
- IPEndPoint hostep = new IPEndPoint (ip, hostPort);
- Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- sock.Connect(hostep);
- byte[] bytesReceived = new byte[5 * 1024];
- int bytes = sock.Receive(bytesReceived, bytesReceived.Length, 0);
- string page = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
- Console.WriteLine(page);
- sock.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement