FrewCen
FrewCen

Reputation: 646

Sending file in C#

Can I send file on one port to more computers at the same time in C#? Like I have code to send by System.Net.Sockets on port 1234and I want to send file to 5 computers. Can I do it at the same time?

Upvotes: 0

Views: 279

Answers (1)

Yahia
Yahia

Reputation: 70369

you can do that if you mean with one port the desitination port...

you will need to use Async or Thread to make the sending parallel... you will have to deal with correctly setting the FileStream sharing so the file can be opened in parallel by the different threads.

see

http://msdn.microsoft.com/en-us/library/5h0z48dh.aspx
http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx
http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx
http://www.csharp-examples.net/create-new-thread/
http://www.developerfusion.com/article/3918/socket-programming-in-c-part-1/2/

EDIT - as per comment :

it doesn't make a difference... you can use ThreadPool and create per destination one work item... see http://msdn.microsoft.com/de-de/library/system.threading.threadpool.aspx and http://www.dotnetperls.com/threadpool

Upvotes: 2

Related Questions