using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class BadBroadcast {
public static void Main()
{
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, 9050);
byte[] data = Encoding.ASCII.GetBytes("This is a test message");
sock.SendTo(data, iep);
sock.Close();
}
}
C# Programmation Réseau: Créer un client TCP asynchrone
pClient()
{
Text = "Asynchronous TCP Client";
Size = new Size(400, 380);
Label label1 = new Label();
label1.Parent = this;
C# Programmation Réseau: Exemple d’une Application de Tchat avec le protocole TCP/IP
];
public NewTcpChat()
{
Text = “New TCP Chat Program”;
Size = new Size(400, 380);
Label label1 = new Label();
label1.Pare
C# Programmation Réseau: Vérifier si l’adresse IP de l’interface réseaux a changée
addr.Address, DateTime.Now + new TimeSpan(0, 0, (int)addr.DhcpLeaseLifetime));
}
}
}
static void Main(string[] args) {
Netw
C# Programmation Réseau: Exemple de Ping
Console.WriteLine("Success - IP Address:{0}", reply.Address, reply.RoundtripTime);
} else {
Consol
C# Programmation Réseau: Comment analyser les Cookies
static void Main(string[] args) {
if(args.Length != 1) {
Console.WriteLine("Usage: CookieDemo ");
return ;
}
// Create a
C# Programmation Réseau: Se connecter un serveur HTTP avec les identifiants
ord);
request.ContentLength = data.Length;
request.ContentType = "text/plain";
using (StreamWriter writer = new StreamWriter(request.GetRequestStre
C# Programmation Réseau: Obtenir les information d’un Serveur DNS
Host name: {0}", iphe.HostName);
foreach(string alias in iphe.Aliases)
{
Console.WriteLine("Alias: {0}", alias);
}
foreach(IPAd
C# Programmation Réseau: Convertir un caractère en son équivalent hexadécimal
using System;
public class MainClass{
public static void Main(){
char testChar = 'e';
if (Uri.IsHexDigit(testChar) == true)
Console.WriteLine("'{0}' is the hexadecimal representation of {1}", testChar, Uri.FromHex(testChar));
else
Console.WriteLine("'{0}' is not a hexadecimal character", testChar);
string returnString = Uri.HexEscape(testChar);
Console.WriteLine("The hexadecimal value of '{0}' is {1}", testChar, returnString);
}
}
C# Programmation Réseau: Recevoir les données d’un serveur de diffusion UDP
int)iep;
Console.WriteLine("Ready to receive...");
byte[] data = new byte[1024];
int recv = sock.ReceiveFrom(data, ref ep);
string stri