Hossein Moradinia
Hossein Moradinia

Reputation: 6244

Send A File In C Sharp with UDP Protocol From A Computer To Other Computer

I Want Send A File From A Computer To Other Computer With UDP protocol.How Can I do this?

I Want A Sample To Send File...

Upvotes: 1

Views: 12088

Answers (4)

Matt Peterson
Matt Peterson

Reputation: 5749

UDP has no inherent knowledge of files (it is much lower in the protocol stack), so it might be worth investigating one of the established UDP-based file transfer protocols. Some of them might have .NET implementations.

Otherwise, you are going to be doing a lot of work on your own (e.g. ensuring that the file is broken up into pieces, making sure that all packets are received AND that they are received in the correct order, etc.)

Upvotes: 2

cecilphillip
cecilphillip

Reputation: 11596

The link below shows various examples of how to send and receive UDP packets with C#

http://www.java2s.com/Code/CSharp/Network/UdpClientMultiReceive.htm

Upvotes: 1

Steve Townsend
Steve Townsend

Reputation: 54158

You can use UdpClient.

Delivery is not guaranteed with UDP - if you have to break the file up, this is especially problematic. See here for a discussion - How to send large data using C# UdpClient?

If this is point-to-point (as the question suggests), it would be simple to write some native code to do this using TransmitFile.

The TransmitFile function transmits file data over a connected socket handle. This function uses the operating system's cache manager to retrieve the file data, and provides high-performance file data transfer over sockets.

Upvotes: 4

Robert Harvey
Robert Harvey

Reputation: 180798

Use the UdpClient Class.

Upvotes: 2

Related Questions