Uses a TcpClient to handle HTTP : TCP Client : Network C# Source Code


Custom Search

C# Source Code » Network » TCP Client »

 

Uses a TcpClient to handle HTTP








    


using System;
using System.Text;
using System.IO;
using System.Net.Sockets;


public class TryTcp {
  public static void Main(String [] args) {
    TcpClient client = new TcpClient("www.navioo.com", 80);
    NetworkStream stream = client.GetStream();
    byte[] send = Encoding.ASCII.GetBytes("GET HTTP/1.0 \r\n\r\n");
    stream.Write(send, 0, send.Length);
    byte[] bytes = new byte[client.ReceiveBufferSize];
    int count = stream.Read(bytes, 0, (int)client.ReceiveBufferSize);
    String data = Encoding.ASCII.GetString(bytes);
    char[] unused = {(char)data[count]};
    Console.WriteLine(data.TrimEnd(unused));
    stream.Close();
    client.Close();
  }
}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Network
» TCP Client