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 1234
and I want to send file to 5 computers. Can I do it at the same time?

- 636
- 1
- 7
- 21
-
Are those computer in one LAN? – svick Aug 07 '11 at 13:33
1 Answers
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

- 69,653
- 9
- 115
- 144
-
Thank you, but if will I don't know to how many computers will i send file? – FrewCen Aug 07 '11 at 13:21