Click here to Skip to main content
11,811,971 members (53,431 online)
Rate this: bad
Please Sign up or sign in to vote.
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 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 17-Mar-10 3:29am
Edited 7-Apr-10 10:46am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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[^].
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

See this below link, this will assists you surely to serve your purpose

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

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

  Print Answers RSS
0 KrunalRohit 354
1 Palash Mondal_ 185
2 CHill60 180
3 OriginalGriff 178
4 Abhinav S 175
0 OriginalGriff 3,888
1 KrunalRohit 2,392
2 CPallini 2,240
3 Maciej Los 2,155
4 ppolymorphe 1,725

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 21 Apr 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100