Prgramation des sockets client/serveur "echange de fichier"

87abdou Messages postés 1 Date d'inscription mercredi 23 avril 2008 Statut Membre Dernière intervention 30 avril 2008 - 30 avril 2008 à 13:06
xmox667 Messages postés 357 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 26 décembre 2011 - 1 mai 2008 à 13:20
je veux devlopper une appliction d'echange de fichier en c#  a base des sockets   si quelqun veut m'aider
merci d'avance ...
A voir également:

1 réponse

xmox667 Messages postés 357 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 26 décembre 2011 4
1 mai 2008 à 13:20
Salut,

Pour envoyer un fichier via une socket il y a la méthode : Socket.SendFile( string )
Un petit exmple de la MSDN: [Socket.SendFile example]

// Establish the local endpoint for the socket.
IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddr = ipHost.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 11000);

// Create a TCP socket.
Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

// Connect the socket to the remote endpoint.
client.Connect(ipEndPoint);

// There is a text file test.txt located in the root directory.
string fileName = "C:\\test.txt";

// Send file fileName to remote device
Console.WriteLine("Sending {0} to the host.", fileName);
client.SendFile(fileName);

// Release the socket.
client.Shutdown(SocketShutdown.Both);
client.Close();

A+
0
Rejoignez-nous