Advertisement
Guest User

Untitled

a guest
May 28th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3. using System.Net.Sockets;
  4. using System.Text;
  5. class test
  6. {
  7. public static void Main(String[] args)
  8. {
  9. string hostName = "india.colorado.edu";
  10. int hostPort = 13;
  11.  
  12. IPAddress ip = Dns.GetHostAddresses(hostName)[0];
  13.  
  14. IPEndPoint hostep = new IPEndPoint (ip, hostPort);
  15. Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  16. sock.Connect(hostep);
  17.  
  18. byte[] bytesReceived = new byte[5 * 1024];
  19. int bytes = sock.Receive(bytesReceived, bytesReceived.Length, 0);
  20. string page = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
  21. Console.WriteLine(page);
  22.  
  23. sock.Close();
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement