Introduction
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.<o:p>
If you want
can changed in code to same message received by all clients<o:p>
Enchantment:-if
server want to send one Client you have developed own.<o:p>
And
special services server had option to send message to all connected client.<o:p>
void CTestServerSocketDlg::OnDataReceived(WPARAM wParam,LPARAM lParam)
{
try
{
CString csTemp;
int mnInstanceNo = (int)lParam;
CClientSocket * pCheckSocket;
pCheckSocket = (CClientSocket * ) m_ClientSocketArray.GetAt(mnInstanceNo);
char szBuff[1024];
memset(szBuff,'\0',sizeof szBuff);
pCheckSocket->Receive(szBuff,1024);
csTemp.Empty();
csTemp.Format("%s",szBuff);
m_ctrlDataRec.InsertString(-1,csTemp);
UpdateData(false);
for ( int i=0;i<MAX_CONNECTION;i++)
{
pCheckSocket = (CClientSocket * )m_ClientSocketArray.GetAt(i);
if(pCheckSocket)
{ if(pCheckSocket->m_nInstanceNo != mnInstanceNo)
{pCheckSocket->Send(szBuff,sizeof szBuff);}
}
}
}
catch(...) { }
I am working at Hyderabad as vc++ software developer,I passed B.Com and B-level from DOEACC (www.doeacc.org.in)through O.U.Campus.