Click here to Skip to main content
11,484,162 members (69,215 online)
Click here to Skip to main content

Multiple Client and Single Server in TCP and Broadcast

, 1 Nov 2007 CPOL 21.5K 1.1K 8
Rate this:
Please Sign up or sign in to vote.
Multiple Client and Single Server in TCP and Broadcast
Screenshot - Message.jpg


Description:-This Server will accept maximum 10 Client. Client sends message to server. Server will broadcast same message to connected all client expect who send. Here I am using word "broadcast" in TCP Stream. Generally broadcast is used in UDP stream.

If you want can changed in code to same message received by all clients

Enchantment:-if server want to send one Client you have developed own.

And special services server had option to send message to all connected client.

void CTestServerSocketDlg::OnDataReceived(WPARAM wParam,LPARAM lParam) 
   CString csTemp; 
   int mnInstanceNo = (int)lParam; // client number who send data 
   CClientSocket  * pCheckSocket;  
   pCheckSocket = (CClientSocket *  ) m_ClientSocketArray.GetAt(mnInstanceNo); 
   char szBuff[1024]; 
   memset(szBuff,'\0',sizeof szBuff); 
   for ( int i=0;i<MAX_CONNECTION;i++) 
    pCheckSocket = (CClientSocket * )m_ClientSocketArray.GetAt(i); 
     {    if(pCheckSocket->m_nInstanceNo != mnInstanceNo) 
    {pCheckSocket->Send(szBuff,sizeof szBuff);}
    }// end for
  }// end try
 catch(...) { }
Screenshot - server.jpg


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


About the Author

Web Developer
India India
I am working at Hyderabad as vc++ software developer,I passed B.Com and B-level from DOEACC ( O.U.Campus.

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 2 Nov 2007
Article Copyright 2007 by sherton
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid