Click here to Skip to main content
Rate this: bad
good
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 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 17-Mar-10 4:29am
Edited 7-Apr-10 11:46am
Moak11.4K
v2
Rate this: bad
good
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[^]
  Permalink  
v2
Rate this: bad
good
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[^].
  Permalink  
v3
Rate this: bad
good
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[^]
  Permalink  

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 21 Apr 2010
Copyright © CodeProject, 1999-2014
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