BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCP Server / DataArrival

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Simo
Guest





PostPosted: Fri Feb 20, 2004 6:09 am    Post subject: TCP Server / DataArrival Reply with quote



I am using D7 PE, Indy 9.00.10.
and am programing TCP stream server application with TIdTCPServer component.

I have a question about it.

How can I detect the data arrival from the client after session connected?

the program can process first data in OnExecute event.
However, next event did not happen.
I'd like to do the data communication and keeping the session.
I need like a DataArrival event of VB.

something mistake?

-
Simo



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Feb 20, 2004 6:46 am    Post subject: Re: TCP Server / DataArrival Reply with quote



"Simo" <simo (AT) ict-osaka (DOT) com> wrote


Quote:
How can I detect the data arrival from the client after session connected?

You don't "detect" it, you wait for it. Indy is not an asynchronous
library. When you perform a read or write operation, it blocks until it
finishes, or an error occurs. Simply call one of the Read...() methods of
the Connection, and when data eventually arrives, it will be read.

Quote:
the program can process first data in OnExecute event.
However, next event did not happen.

Please show your actual code. You are probably not using it properly.
OnExecute is triggered in a loop for the lifetime of the connection. It is
not possible for it to not be triggered, unless you are blocking its thread
somehow.


Gambit



Back to top
Simo
Guest





PostPosted: Fri Feb 20, 2004 6:59 am    Post subject: Re: TCP Server / DataArrival Reply with quote



Thank you for your quick reply.

Quote:
You don't "detect" it, you wait for it. Indy is not an asynchronous
library. When you perform a read or write operation, it blocks until it
finishes, or an error occurs. Simply call one of the Read...() methods of
the Connection, and when data eventually arrives, it will be read.

I see.

Quote:
the program can process first data in OnExecute event.
However, next event did not happen.

Please show your actual code. You are probably not using it properly.
OnExecute is triggered in a loop for the lifetime of the connection. It
is
not possible for it to not be triggered, unless you are blocking its
thread
somehow.

my description was not enough.
exactly, when the client connected to server, the client was sending a
first data.

well, which component is better to use the asynchronous commnication of
TCP/IP
binary mode?

Regards.
---
Simo.


Back to top
Lee_Nover
Guest





PostPosted: Fri Feb 20, 2004 8:02 am    Post subject: Re: TCP Server / DataArrival Reply with quote

then read the data in the server's OnConnect event
Read will block until data is available for reading


"Simo" <simo (AT) amy (DOT) hi-ho.ne.jp> wrote

Quote:
Thank you for your quick reply.

You don't "detect" it, you wait for it. Indy is not an asynchronous
library. When you perform a read or write operation, it blocks until it
finishes, or an error occurs. Simply call one of the Read...() methods
of
the Connection, and when data eventually arrives, it will be read.

I see.

the program can process first data in OnExecute event.
However, next event did not happen.

Please show your actual code. You are probably not using it properly.
OnExecute is triggered in a loop for the lifetime of the connection. It
is
not possible for it to not be triggered, unless you are blocking its
thread
somehow.

my description was not enough.
exactly, when the client connected to server, the client was sending a
first data.

well, which component is better to use the asynchronous commnication of
TCP/IP
binary mode?

Regards.
---
Simo.




Back to top
Martin James
Guest





PostPosted: Fri Feb 20, 2004 10:47 am    Post subject: Re: TCP Server / DataArrival Reply with quote

Quote:
the program can process first data in OnExecute event.
However, next event did not happen.

Please show your actual code. You are probably not using it properly.
OnExecute is triggered in a loop for the lifetime of the connection. It
is
not possible for it to not be triggered, unless you are blocking its
thread
somehow.

my description was not enough.
exactly, when the client connected to server, the client was sending a
first data.

Fine - the read call in onExecute will then return with the data received
from the client. Handle it, do whatever it is you do with client data, exit
the onExecute handler - it will be called again so it can read the next
chunk of data from the client.

Quote:
well, which component is better to use the asynchronous commnication of
TCP/IP
binary mode?

It's no problem to perform, say, writes, while waiting for a read to return,
you just need to write from another thread. The 'nornal' app events are
fired in the main thread, so, looking at the app as a whole, Indy *is*
asynchronous.

You can, with a little more coding and a 'synchronize' or 'postMessage' or
two, make Indy fire events in the main thread like VB, but for many apps
this is just not neccessary and defeats the simplicity of the Indy
'thread-per-client' design that makes handling multiple clients easy.

If you have to have main-thread events, look at ICS, (Google for it). ICS
is very good if you just have to have an 'asynchronous' component set for
some reason. With such components will come all the awkwardness, latency &
poor responsiveness you get with VB, eg any waits or I/O delays will affect
*all* clients and the GUI, not just the client requesting the wait. Get
reday with your 'hourglass' cursor...


Rgds,
Martin



Back to top
Eric Jansen
Guest





PostPosted: Fri Feb 20, 2004 12:13 pm    Post subject: Re: TCP Server / DataArrival Reply with quote

"Simo" <simo (AT) amy (DOT) hi-ho.ne.jp> schreef in bericht
news:4035b0af$1 (AT) newsgroups (DOT) borland.com...
Quote:
well, which component is better to use the asynchronous commnication of
TCP/IP
binary mode?

I have written a data pump last year (one to many data distributor) in a
single-threaded service, using non-blocking sockets, with the TSocketserver
component. This was the standard Borland component (source included) which
came with D5, before Indy was incorporated in Delphi. I don't know if it is
still there in D7, but I have had very little problems with it. The only
thing I changed in the component (which was easy, because the source was
included) was the connection backlog setting (it was always SOMAXCONN=5).

The service is now in production, feeding about 80 clients now with a
datastream of 2-5 kbyte/s per client. I have stress tested it with 250
clients without any problems.

If the component is no longer there, you might also try the ICS
socketserver. I haven't used it, but I have excellent experiences with the
non-blocking ICS client components (HTTP and FTP).

hth,
Eric Jansen



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Feb 20, 2004 9:07 pm    Post subject: Re: TCP Server / DataArrival Reply with quote


"Simo" <simo (AT) amy (DOT) hi-ho.ne.jp> wrote


Quote:
exactly, when the client connected to server, the client was sending
a first data.

That is perfectly fine. The OnExeute event will catch that.

Quote:
well, which component is better to use the asynchronous commnication
of TCP/IP binary mode?

There is nothing wrong with continuing to use Indy for this. That is why I
asked you to please show your actual code, because you are probably just
mis-using it.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.