Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C# Programmation Réseau: Ecrire des données à travers le réseaux

 
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Net.Sockets;
 
 
class Program {
    static void Main(string[] args) {
        TcpClient client = new TcpClient();
        IPHostEntry host = Dns.GetHostByName("www.google.com");
        client.Connect(host.AddressList[0]8000);
 
        NetworkStream clientStream = client.GetStream();
 
        string request = "LIST";
        byte[] requestBuffer = Encoding.ASCII.GetBytes(request);
        clientStream.Write(requestBuffer, 0, requestBuffer.Length);
 
        byte[] responseBuffer = new byte[256];
        MemoryStream memStream = new MemoryStream();
        int bytesRead = 0;
        do {
            bytesRead = clientStream.Read(responseBuffer, 0256);
            memStream.Write(responseBuffer, 0, bytesRead);
        } while (bytesRead > 0);
 
 
 
    }
}
 
 

No comments yet.

Leave a Comment