Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages
Started by Vladimir Stefanovic
Mon, 16 Aug 2004 12:20
How to skip non-listening servers?
Author: Vladimir Stefanovic
Date: Mon, 16 Aug 2004 12:20
Date: Mon, 16 Aug 2004 12:20
42 lines
2055 bytes
2055 bytes
Hi,
I wanted to send instant messages from one PC (TClientSocket) to
some other PCs (TServerSocket) in LAN which are in the list:
Rcp = new TLanRecipients();
Rcp->Add ( "1.1.1.1", "Message 1" );
Rcp->Add ( "1.1.1.2", "Message 2" );
Rcp->Add ( "1.1.1.3", "Message 3" );
// ...
Port for both sides is nagotiated before (say 1200), and ClientType
is ctBlocking. ServerType is stNonBlocking.
void TLanService::SendLanMessages()
{
for ( int i=0; i<Rcp->Count(); i++ )
{
ClientSocket->Active = false;
ClientSocket->Address = Rcp->GetIP( i );
ClientSocket->Active = true;
if ( ClientSocket->Active == true )
ClientSocket->Socket->SendText( Rcp->GetMsg( i ) );
}
}
This code works fine *only* when ALL three destination PCs in LAN
are active and waiting for message. But when, for example, the
first in the list is not active (the service is stopped/paused/
uninstalled), the loop waits - and other recipients though cannot
be informed.
What should I change in the concept of this code, to ignore the
non-listening PCs?
Best regards,
Vladimir Stefanovic
Re: How to skip non-listening servers?
Author: Vladimir Stefanovic
Date: Tue, 17 Aug 2004 13:44
Date: Tue, 17 Aug 2004 13:44
17 lines
1070 bytes
1070 bytes
> ClientSocket->Active = true;
This way:
try
{
ClientSocket->Active = true;
}
catch ( ... )
{
// Do nothing ...
}
Best regards,
Vladimir Stefanovic
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads