Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
I am making simple one on server side & one on client side application for transferring file from one location to another location or from one computer to another computer if computers are in network.

I used the code from http://www.codeproject.com/KB/IP/SocketFileTransfer.aspx. It is working & file transferred successfully.

But i need to transfer file from server to multiple clients at a time. I mean on server, there should be more than two client can connect & they can receive file at same time.

I don't know how to maintain queue for that & how to pass CSocket object to method using Threading & any other way.

I also don't know how to prepare queue of CSocket objects.

So, please if you have any solution or alternative way then please tell me....
Posted
Updated 7-Apr-10 10:46am
v2

You may want to use a multicast socket, which would send the data simultaneously to any clients.

I've not done anything with it myself, but here are some links that you may find useful:

Wrapper Class for setting up a multicast socket here[^]

MSDN Pages on the subject, including example code here[^]
 
Share this answer
 
v2
Here are some more CodeProject articles with alternatives that might help:

- A reusable, high performance, socket server class - Part 1[^]
- Asynchronous socket communication[^]
- Multithreaded server class with example of HTTP server[^]

With these examples you can choose between single threaded (asynchronous) and multi threaded networking. Generally, I would not use MFC's CSocket class, it's known to be unreliable and inefficient. When doing file transfer in the LAN, you probably want to use something fast to serve multiple clients. If you need to use MFC, check CAsyncSocket[^].
 
Share this answer
 
v3
See this below link, this will assists you surely to serve your purpose

Single Server With Multiple Clients : a Simple C++ Implementation[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900