ew IPEndPoint(IPAddress.Any, 0);
data = newsock.Receive(ref sender);
Console.WriteLine("Message received from {0}:", sender.ToString());
Con
Author: user
C# Programmation Réseau: Vérifier si un URL est Relative ou absolue
ftware is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all co
C# Programmation Réseau: Accéder à la famille d’adresse IP(IPV4 ou IPV6)
using System;
using System.Net;
class MainClass {
public static void Main(string[] args) {
foreach (string comp in args) {
try {
IPAddress[] addresses = Dns.GetHostEntry(comp).AddressList;
foreach (IPAddress address in addresses) {
Console.WriteLine("{0} = {1} ({2})",
comp, address, address.AddressFamily);
}
} catch (Exception ex) {
Console.WriteLine("{0} = Error ({1})", comp, ex.Message);
}
}
}
}
C# Programmation Réseau: Gérer les socket dans un Thread
void sendPackets()
{
Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
sock.SetSo
C# Programmation Réseau: Décomposer un objet 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: Afficher toutes les interfaces 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: Accéder au Serveur de calcul créé précédement
System.Console.WriteLine("Could not locate server");
else
{
int a = Convert.ToInt32(argv[0]);
int b = Convert.ToInt32(argv[1]);
C# Programmation Réseau: Exemple de connexion à une passerelle DSML à l’aide de SOAP sur HTTP
password";
DsmlSoapHttpConnection dsmlConnection = new DsmlSoapHttpConnection(identifier);
string baseDN = null;
string ldapSearchFil
C# Programmation Réseau: Exemple d’un Serveur de diffusion avec le protocole UDP
oding.ASCII.GetBytes(hostname);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
sock.SendTo(data, iep1);
sock.
C# Programmation Réseau: Diffuser un message avec le protocole UDP
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();
}
}