Article View: borland.public.cppbuilder.internet.socket
Article #5474How To Send To Multiple Clients
From: mike
Date: Sat, 07 Aug 2004 16:18
Date: Sat, 07 Aug 2004 16:18
54 lines
2729 bytes
2729 bytes
Hope someone can help me with this, another socket problem.
I have a single Server Socket running in blocking mode, so each client has
its own thread. Everything I have tested works great.
Now, under some conditions the Server receives a message and the Server must
send a message to all the connected clients. So I declared a public routine
SendToAllClients(). The information that needs to be sent to all the clients
is also placed in a public variable.
So what I then do is the following:
In the receiving Server Thread;
for( int i = 0; i <
Form1->ServerSocket2->Socket->ActiveConnections; i++ )
{
TServerClientWinSocket *ClientSocket =
static_cast<TServerClientWinSocket*>(
Form1->ServerSocket2->Socket->Connections[ i ] ) ;
TMyServerThread *Thread =
static_cast<TMyServerThread*>(
Form1->ServerSocket2->Socket->GetClientThread( ClientSocket ) ) ;
if( Thread )
{
Thread->InfoToSendToAllClients =
DataToSendOutToClient ;
;
Thread->SendAnActionToSendToAClient()
;
}
}
}
So what I am trying to do is send the data contained in
DataToSendOutToClient to all the clients connected. Now everything seems to
work fine, that is the public routine Thread->SendAnActionToSendToAClient()
does the send but what happens is shortly after the actual socket send takes
place the socket is dropped. There is no exception or error that I can see,
it just simply drops.
So my question is, in a threaded server socket, what is the proper way to
send a message to all connected clients.
Thanks for any information.
Mike
Technical Details
Message-ID:
<41166225$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.freenet.de!80.239.136.22.MISMATCH!frankfurt1.telia.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,14632bcd79989ffc,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "mike" <mfbrowne@earthlink.net> Newsgroups: borland.public.cppbuilder.internet.socket Subject: How To Send To Multiple Clients Date: Sat, 7 Aug 2004 12:18:27 -0400 Lines: 59 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 68.204.190.196 Message-ID: <41166225$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1091985957 68.204.190.196 (8 Aug 2004 10:25:57 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.freenet.de!80.239.136.22.MISMATCH!frankfurt1.telia.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail