Thread View: borland.public.cppbuilder.internet.socket
7 messages
7 total messages
Started by Michele Santucci
Fri, 09 Jul 2004 15:04
TServerSocket problems
Author: Michele Santucci
Date: Fri, 09 Jul 2004 15:04
Date: Fri, 09 Jul 2004 15:04
24 lines
1657 bytes
1657 bytes
Hello!
I have several questions:
1) I would like to know how to know/set the address on wich the
TServerSocket listen since TServerSocket->Socket->LocalAddress is always
"0.0.0.0" and is read only.
2) I would like also to know how to track the IP address of a connected
client.
3) Last but not least ... is it possible to stop listening after the first
connection? I mean if I set the Active property to false the server stops
EVERY activity included each connected clients (I would like to know how to
stop listening WITHOUT closing the ongoing connections).
Best regards...
TuX
--
================================
Michele Santucci
Software Development Manager
Celin Avio S.r.l.
Via Fontevivo, 21/M 19100 La Spezia
tel. +39-0187564080
================================
Re: TServerSocket problems
Author: Hans Galema
Date: Fri, 09 Jul 2004 15:10
Date: Fri, 09 Jul 2004 15:10
23 lines
1715 bytes
1715 bytes
Michele Santucci wrote: > 1) I would like to know how to know/set the address on wich the > TServerSocket listen since TServerSocket->Socket->LocalAddress is always > "0.0.0.0" and is read only. No, not always. As soon a a client connects it will contain an IP-address. > 2) I would like also to know how to track the IP address of a connected > client. Socket->RemoteAddress; in the Socket parameter of all events. > 3) Last but not least ... is it possible to stop listening after the first > connection? I mean if I set the Active property to false the server stops > EVERY activity included each connected clients (I would like to know how to > stop listening WITHOUT closing the ongoing connections). To my knowledge: not possible. Hans.
Re: TServerSocket problems
Author: Remy Lebeau (TeamB)
Date: Fri, 09 Jul 2004 18:46
Date: Fri, 09 Jul 2004 18:46
43 lines
2179 bytes
2179 bytes
"Michele Santucci" <michele.santucci.nospam@nospam.celinavio.it> wrote in
message news:40eeb440$1@newsgroups.borland.com...
> 1) I would like to know how to know/set the address
> on wich the TServerSocket listen since
> TServerSocket->Socket->LocalAddress is always
> "0.0.0.0" and is read only.
The easiest way is to derive a new class from TServerSocket and promote the
existing protected Address property to public, ie:
class TMyServerSocket : public TServerSocket
{
public:
__fastcall TMyServerSocket(TComponent Owner) : TServerSocket(Owner)
{}
__property Address;
};
TServerSocket already calls bind() using the Address, but since the Address
is not exposed, it is always empty. Why Borland did not expose it
originally, I do not know.
> 2) I would like also to know how to track the IP address
> of a connected client.
TCustomWinSocket has a RemoteAddress property. All of the event handlers of
TServerSocket have a TCustomWinSocket parameter specifying which client is
triggering each event.
> 3) Last but not least ... is it possible to stop listening after the
> first connection?
No.
> I would like to know how to stop listening WITHOUT closing
> the ongoing connections.
TServerSocket does not support that.
Gambit
Re: TServerSocket problems
Author: Remy Lebeau (TeamB)
Date: Fri, 09 Jul 2004 18:49
Date: Fri, 09 Jul 2004 18:49
14 lines
1400 bytes
1400 bytes
"Hans Galema" <dontusethis@dontusethis.nl> wrote in message news:40eeb51f@newsgroups.borland.com... > No, not always. As soon a a client connects it will contain an IP-address. The LocalAddress property specifies the IP address that the server is listening on, not the IP that client's connect to. It does not change during the lifetime of the server's listening. In the case of "0.0.0.0", it means the server is listening on all available IP addresses on the server machine. Gambit
Re: TServerSocket problems
Author: Hans Galema
Date: Fri, 09 Jul 2004 20:45
Date: Fri, 09 Jul 2004 20:45
15 lines
1583 bytes
1583 bytes
Remy Lebeau (TeamB) wrote: >>No, not always. As soon a a client connects it will contain an IP-address. > > > The LocalAddress property specifies the IP address that the server is > listening on, not the IP that client's connect to. It does not change > during the lifetime of the server's listening. In the case of "0.0.0.0", it > means the server is listening on all available IP addresses on the server > machine. Indeed. What I meant to say was that as soon as a client connects the local IP is in the clients Socket->LocalAddress property. Hans.
Re: TServerSocket problems
Author: Remy Lebeau (TeamB)
Date: Fri, 09 Jul 2004 23:10
Date: Fri, 09 Jul 2004 23:10
14 lines
1410 bytes
1410 bytes
"Hans Galema" <dontusethis@dontusethis.nl> wrote in message news:40ef03a7@newsgroups.borland.com... > Indeed. What I meant to say was that as soon as > a client connects the local IP is in the clients > Socket->LocalAddress property. Michele was not referring to the Socket that is specified in event handlers, but instead was referring to the Socket property of TServerSocket. They are very different sockets. Gambit
Re: TServerSocket problems
Author: Hans Galema
Date: Sat, 10 Jul 2004 09:08
Date: Sat, 10 Jul 2004 09:08
9 lines
1439 bytes
1439 bytes
Remy Lebeau (TeamB) wrote: > Michele was not referring to the Socket that is specified in event handlers, > but instead was referring to the Socket property of TServerSocket. As you can see I was certainly aware of that. I only made a mistake by exchanging two LocalAddress properties. Hans.
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