Click here to Skip to main content
16,006,341 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralPorting Application from Unix to Windows Pin
Nitin Shukla1-May-02 23:05
Nitin Shukla1-May-02 23:05 
GeneralRe: Porting Application from Unix to Windows Pin
Jeremy Falcon2-May-02 16:46
professionalJeremy Falcon2-May-02 16:46 
GeneralThreads Pin
eynats1-May-02 23:02
eynats1-May-02 23:02 
GeneralRe: Threads Pin
Joao Vaz2-May-02 0:40
Joao Vaz2-May-02 0:40 
General!Threads Pin
eynats1-May-02 22:57
eynats1-May-02 22:57 
GeneralWould Like To Architect As Well Program Client/Server Using CSocketFile For Transferring a "Case" Object... Pin
G.V.Bhaskar1-May-02 21:38
G.V.Bhaskar1-May-02 21:38 
GeneralWould Like To Know How To Architect As Well Program Client/Server using CSocketFile For Transferring a "Case" Object... Pin
G.V.Bhaskar1-May-02 21:33
G.V.Bhaskar1-May-02 21:33 
GeneralRe: Would Like To Know How To Architect As Well Program Client/Server using CSocketFile For Transferring a "Case" Object... Pin
Alwin751-May-02 22:04
Alwin751-May-02 22:04 
Hi there,

To allow the server app to forward received objects to other clients, you first need
to expand your server to allow multiple clients to connect. Just call ServerSocket.Accept() in a loop and store the returned CSocket (or derived) objects, one for each connected client, somewhere (you could use a CList for this).

I guess the easiest way to handle client requests is to derive a class from CSocket and pass instances of these objects to Accept(). By overriding the OnReceive() method (see CSocket's base class CAsyncSocket in the online docs), you can cause code to be executed then data is received from a client. Just receive the object like you did in your example and forward it to all other connected clients using the socket objects you stored.

You should also override the OnClose() method to remove socket objects from the socket list if the connection is being closed.

As an aside, you could change your CaseId and CaseName member variables of CCase to CStrings, which allows you to (de)serialise them using the << and >> operators, ie.

ar << CaseID << CaseName << ConsultationCount;

Hope this helps (and works Wink | ;) )

Alwin
GeneralWindows Media Player Pin
Hans Ruck1-May-02 21:25
Hans Ruck1-May-02 21:25 
GeneralRe: Windows Media Player Pin
1-May-02 22:24
suss1-May-02 22:24 
GeneralFinal Compile Problem Almost there!! Pin
Kevinnrb1-May-02 20:13
Kevinnrb1-May-02 20:13 
GeneralRe: Final Compile Problem Almost there!! Pin
Christian Graus1-May-02 20:42
protectorChristian Graus1-May-02 20:42 
GeneralToolBars Pin
gammprog1-May-02 19:47
gammprog1-May-02 19:47 
GeneralRe: ToolBars Pin
Tom Archer1-May-02 20:10
Tom Archer1-May-02 20:10 
GeneralVideo Camera - Please Help Pin
Sameer Maggon1-May-02 19:19
Sameer Maggon1-May-02 19:19 
Generalpriority_queue (STL) Pin
cloudtwist1-May-02 18:20
cloudtwist1-May-02 18:20 
GeneralRe: priority_queue (STL) Pin
Paul M Watt1-May-02 19:01
mentorPaul M Watt1-May-02 19:01 
QuestionWhat's wrong with my code? Pin
MaTrIX2k21-May-02 17:30
MaTrIX2k21-May-02 17:30 
GeneralSetWindowsHookEx Help me please Pin
1-May-02 16:45
suss1-May-02 16:45 
GeneralRe: SetWindowsHookEx Help me please Pin
1-May-02 18:00
suss1-May-02 18:00 
GeneralRe: SetWindowsHookEx Help me please Pin
Sameer Maggon1-May-02 18:59
Sameer Maggon1-May-02 18:59 
GeneralRe: SetWindowsHookEx Help me please Pin
1-May-02 19:31
suss1-May-02 19:31 
GeneralRe: SetWindowsHookEx Help me please Pin
Tom Archer1-May-02 20:55
Tom Archer1-May-02 20:55 
GeneralRe: SetWindowsHookEx Help me please Pin
1-May-02 21:27
suss1-May-02 21:27 
GeneralRe: SetWindowsHookEx Help me please Pin
Tom Archer1-May-02 22:02
Tom Archer1-May-02 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.