Board index » delphi » TServerSocket

TServerSocket


2004-04-05 09:52:04 AM
delphi58
Hi
I would like to find out why the TServerSocket.ActiveConnections will have
more connections than my actual list of connections?
When each of the client connects to the server, i will keep track of the
connection in a List called MyList. As time goes by, the
TServerSocket.ActiveConnection will return a value more than the number of
items in MyList.
Could someone help me.Is there a way to make sure that the number of
ActiveConnections in TServerSocket is the same as the number of items in
MyList.
Thanks
Chris
 
 

Re:TServerSocket

"Christopher Chuah" <XXXX@XXXXX.COM>writes
Quote
I would like to find out why the TServerSocket.ActiveConnections
will have more connections than my actual list of connections?
Because TServerSocket does not always detech closing connections and thus
does not remove them from the list.
Quote
Could someone help me.Is there a way to make sure that the number
of ActiveConnections in TServerSocket is the same as the number
of items in MyList.
Sure - by not relying on ActiveConnections at all in the first place.
Beyond that, if you want to use ActiveConnections, then you need to provide
more details about your setup, you are probably not using the sockets
correctly and thus they become mismanaged.
Gambit
 

Re:TServerSocket

Hi
1. HOw do i know that the connections has been closed? I don rely on the
Active Connections but i do find it funny why it has more than what i have
in myList.
2. When the client socket connects to the server, i store a socket into
myList. myList is a TStringList. Whenever i send a command to the client, i
will lookup on the socket in myList and send the text via the socket. But
what i don understand is why i have more ActiveConnections when i could send
text to each individual sockets in myList.
3. Please advise on how to properly manage the sockets. I really don know
much about socket connections.
Thanks
Chris
"Remy Lebeau (TeamB)" <XXXX@XXXXX.COM>writes
Quote

"Christopher Chuah" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...

>I would like to find out why the TServerSocket.ActiveConnections
>will have more connections than my actual list of connections?

Because TServerSocket does not always detech closing connections and thus
does not remove them from the list.

>Could someone help me.Is there a way to make sure that the number
>of ActiveConnections in TServerSocket is the same as the number
>of items in MyList.

Sure - by not relying on ActiveConnections at all in the first place.
Beyond that, if you want to use ActiveConnections, then you need to
provide
more details about your setup, you are probably not using the sockets
correctly and thus they become mismanaged.


Gambit


 

Re:TServerSocket

"Christopher Chuah" <XXXX@XXXXX.COM>writes
Quote
1. HOw do i know that the connections has been closed?
That depends on how you are using the server socket to begin with. Is it in
blocking or non-blocking mode?
Quote
But what i don understand is why i have more ActiveConnections
when i could send text to each individual sockets in myList.
I already told you why - disconnects are not always detected automatically.
Besides, you didn't specify when and why you remove items from your own list
anyway.
Gambit
 

Re:TServerSocket

Hi Remy
I am using the non-blocking sockets.
Hence when there is a disconnect from the client side, the TServerSocket
will generate a socket disconnect event. This will then trigger my program
to remove the socket from myList of sockets.
At the same time, if there is a socket Error, it will also disconnect the
existing socket and remove the socket my myList too.
Is there a way to find out whether the sockets in ServerSocket of
ActiveConnections, which sockets are dead and which are alive?
thanks
chris
"Remy Lebeau (TeamB)" <XXXX@XXXXX.COM>writes
Quote

"Christopher Chuah" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...

>1. HOw do i know that the connections has been closed?

That depends on how you are using the server socket to begin with. Is it
in
blocking or non-blocking mode?

>But what i don understand is why i have more ActiveConnections
>when i could send text to each individual sockets in myList.

I already told you why - disconnects are not always detected
automatically.
Besides, you didn't specify when and why you remove items from your own
list
anyway.


Gambit


 

Re:TServerSocket

"Christopher Chuah" <XXXX@XXXXX.COM>writes
Quote
Is there a way to find out whether the sockets in ServerSocket of
ActiveConnections, which sockets are dead and which are alive?
Not without actually accessing the sockets and reading from or writing to
them.
Gambit
 

Re:TServerSocket

When freeing a TServerSocket in thread blocking mode. Do you need to
terminate any
threads that are running or is this done automatically.
Thanks
James
 

Re:TServerSocket

"James Byrne Mx" <XXXX@XXXXX.COM>writes
Quote
When freeing a TServerSocket in thread blocking mode.
Do you need to terminate any threads that are running
or is this done automatically.
It is done automatically.
Gambit
 

Re:TServerSocket

Hello
When client connects it generates an ServerClientConnect event. When the
same client make another connection without disconnecting the first one it
generates the event again. How can I do to disconnect the first instance and
just accept the new one?
Thanks for any help.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/7/2004
 

Re:TServerSocket

Hello,
How can I create TServerSocket (and also TClientSocket) component without
placing it on the Form. I'd like to create it dynamically in the
included file.
When I try to use constructor new TServerSocket(this) obviously it's
impossible, because there is no such constructor using my own class which
isn't a valid component
Tomek
 

Re:TServerSocket

bigtommy writes:
Quote
How can I create TServerSocket (and also TClientSocket) component without
placing it on the Form. I'd like to create it dynamically in the
included file.
In the 'included file' ? Please explain. Of course you can create
an instance of TServerSocket dynamically.
Quote
When I try to use constructor new TServerSocket(this) obviously it's
impossible, because there is no such constructor using my own class which
isn't a valid component
This is all not obvious and/or clear for me. Please be a bit more specific.
TServerSocket *ServerSocket = new TServerSocket ( NULL );
// use ...
delete ServerSocket;
Hans.
 

Re:TServerSocket

Actually you have just solved my problem. Thanks a lot. I haven't tried
constructor with NULL parameter before. It works fine.
Thanks a lot again
Tomek
 

Re:TServerSocket

Hi
I'm using Delphi 7
In which palette I can find TServerSocket ?
Thanks
 

Re:TServerSocket

Quote
I'm using Delphi 7
In which palette I can find TServerSocket ?
TServerSocket has been deprecated in Delphi 7. It is not installed by
default. You must manually install dclsockets70.bpl. You should use Indy or
ICS.
ICS is freeware with full source code and works with all Delphi versions
from version 1 to version 2006. It is included by Borland on the
companion/partner CD you can find in your Delphi 7 (an other) box. You can
also download full source code from www.overbyte.be
 

Re:TServerSocket

Quote
You should use Indy or ICS.
François, you constantly forget to mention Synapse.
www.ararat.cz/synapse/
Why? ;-)