Console.WriteLine("Cookie:");
Console.WriteLine("{0} = {1}", cook.Name, cook.Value);
Console.WriteLine("Domain: {0}", cook
Author: user
C# Programmation Réseau: Envoyer un fichier par email
msg.Body = "This is a message.";
msg.Attachments.Add(new Attachment("7.cs", "text/plain"));
msg.Attachments.Add(new Attach
C# Programmation Réseau: Vérifier si le port d’un URI est pour le schema par défaut
using System;
public class MainClass{
public static void Main(){
// Create Uri
Uri uriAddress = new Uri("http://www.yourDomain.com/index.htm#search");
Console.WriteLine(uriAddress.Fragment);
Console.WriteLine("Uri {0} the default port ", uriAddress.IsDefaultPort ? "uses" : "does not use");
Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path));
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());
}
}
C# Programmation Réseau: Trouver un Serveur par son nom
using System;
using System.Net;
class AddressSample {
public static void Main() {
IPHostEntry ihe = Dns.GetHostByName(Dns.GetHostName());
IPAddress myself = ihe.AddressList[0];
Console.WriteLine("The NONE address is: {0}",myself);
}
}
C# Programmation Réseau: Exemple d’une application qui accède aux routeurs CISCO
Router()
{
Text = "Cisco Router Utilization";
Size = new Size(400, 380);
Label label1 = new Label();
label1.Parent = this;
lab
C# Programmation Réseau: Afficher le hashCode d’un Uri
using System;
public class MainClass{
public static void Main(){
// Create Uri
Uri uriAddress = new Uri("http://www.yourDomain.com/index.htm#search");
Console.WriteLine(uriAddress.Fragment);
Console.WriteLine("Uri {0} the default port ", uriAddress.IsDefaultPort ? "uses" : "does not use");
Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path));
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());
}
}
C# Programmation Réseau: Créer à un client TCP
(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
try
{
server.Connect(ipep);
} catch (SocketE
C# Programmation Réseau: Afficher le nom de l’interface réseaux
using System;
using System.Net.NetworkInformation;
class MainClass {
static void Main() {
if (NetworkInterface.GetIsNetworkAvailable()) {
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in interfaces) {
Console.WriteLine("Interface Name: {0}", ni.Name);
}
} else {
Console.WriteLine("No network available.");
}
}
}
C# Programmation Réseau: Résolution de nom de domaine
using System;
using System.Net;
public class DNSNameResolution
{
[STAThread]
static void Main(string[] args)
{
IPHostEntry MyHost = Dns.Resolve(args[0]);
foreach (IPAddress MyIP in MyHost.AddressList)
{
Console.WriteLine(MyIP.Address);
}
}
}
C# Programmation Réseau: Obtenir une adresse IP
using System;
using System.Net;
class AddressSample {
public static void Main() {
IPAddress test1 = IPAddress.Parse("192.168.1.1");
Console.WriteLine("The test address is: {0}", test1.ToString());
}
}