application client /serveur
bonjour,
J'ai un code qui permet de réaliser une application client/serveur, je souhaiterais comprendre ligne par ligne ce code.
code du serveur :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
class serveur
{
static void Main(string[] args)
{
int i;
IPHostEntry iphe = Dns.Resolve("localhost");
IPEndPoint ipep = new IPEndPoint(iphe.AddressList[0], 8080);
TcpListener s = new TcpListener(ipep);
s.Start();
TcpClient c = s.AcceptTcpClient();
Stream str = c.GetStream();
byte[] b = new byte[50];
String sb;
if ((i = str.Read(b, 0, 50)) != -1)
{
sb = Encoding.ASCII.GetString(b);
Console.Write(sb);
}
str.Close();
c.Close();
}
} |
code client :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
class client
{
static void Main(string[] args)
{
TcpClient c = new TcpClient("localhost", 8080);
Stream str = c.GetStream();
byte[] b;
b = Encoding.ASCII.GetBytes("Hello World");
str.Write(b, 0, b.Length);
str.Close();
c.Close();
}
} |
merci d'avance pour votre aide.