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 

Indy reading from a server and writing to a client

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





PostPosted: Thu Sep 15, 2005 5:27 pm    Post subject: Indy reading from a server and writing to a client Reply with quote



I'm trying to write an image server that can read and write as the same
time. I explain :

My TCPServer (SERVER1) recieve a request for a file from a TCPClient.
This file is locate in another TCPServer (SERVER2). In the thread of the
TCPServer (SERVER1) i create a new TCPClient that connect to the SERVER2 and
start downloading the file to the server to send it to the client that have
request it.
Doing that with whole file is no a problem (dowloading all the file, via
a readstream, to the SERVER1 and writing it to the client, via a
writestream). The problem is that i need to send the file to the client
while the file is been downloading from the SERVER2.

TCPCLIENT --request file--> SERVER1 -- requestfile--> SERVER2
TCPCLIENT <--- sendfile-- SERVER1 <-- sendfile -- SERVER2

I think that could be down with writebuffer an readbuffer or something
like that...

any help will be welcome..

thanks


Back to top
Guillem
Guest





PostPosted: Fri Sep 16, 2005 7:40 am    Post subject: Re: Indy reading from a server and writing to a client Reply with quote



Hi,

Jose Maria Veneroso wrote:

Quote:
My TCPServer (SERVER1) recieve a request for a file from a TCPClient.
This file is locate in another TCPServer (SERVER2). In the thread of
the TCPServer (SERVER1) i create a new TCPClient that connect to the
SERVER2 and start downloading the file to the server to send it to
the client that have request it. Doing that with whole file is no a
problem (dowloading all the file, via a readstream, to the SERVER1
and writing it to the client, via a writestream). The problem is that
i need to send the file to the client while the file is been
downloading from the SERVER2.

TCPCLIENT --request file--> SERVER1 -- requestfile--> SERVER2
TCPCLIENT <--- sendfile-- SERVER1 <-- sendfile -- SERVER2

I think that could be down with writebuffer an readbuffer or
something like that...

i can't tell you how to do it exactly but, have you thought about

1- SERVER2 splits the file in several chunks

2- SERVER2 begins to transmit chunks to SERVER1's tcpClient

3- Whenever SERVER1's tcpClient has received a complete chunk, its
tcpServer gets it and begins to send it to the TCPCLIENT. Meanwhile,
its tcpClient component continues to download chunks until it has all
of them

4- TCPCLIENT receives chunks and saves them to some temp folder. When
it has received all chunks it rebuilds the file.

5 - Et voilŕ!


Good luck
--
Best regards :)

Guillem Vicens
Dep. Informática Green Service S.A.
www.clubgreenoasis.com
--
in order to contact me remove the -nospam

Back to top
Martin James
Guest





PostPosted: Fri Sep 16, 2005 9:13 am    Post subject: Re: Indy reading from a server and writing to a client Reply with quote



Quote:
My TCPServer (SERVER1) recieve a request for a file from a TCPClient.

OK

Quote:
This file is locate in another TCPServer (SERVER2).

OK

In the thread of the
Quote:
TCPServer (SERVER1) i create a new TCPClient that connect to the SERVER2
and
start downloading the file to the server to send it to the client that
have
request it.

Hmm..... I don't think that you are going to get away with a simple
solution.

Quote:
Doing that with whole file is no a problem (dowloading all the file,
via
a readstream, to the SERVER1 and writing it to the client, via a
writestream). The problem is that i need to send the file to the client
while the file is been downloading from the SERVER2.

TCPCLIENT --request file--> SERVER1 -- requestfile--> SERVER2
TCPCLIENT <--- sendfile-- SERVER1 <-- sendfile -- SERVER2

I think that could be down with writebuffer an readbuffer or something
like that...

To do this at all efficiently, you are probably going to need another thread
to run the client that gets the file from SERVER2, an inter-thread comms P-C
queue and a pool of buffers. It's the only way I know of to get the two TCP
streams to run at the same time. The SERVER2 client thread could then queue
buffers to the SERVER1 peer thread that then sends the buffers to the
TCPCLIENT as soon as it gets them. While this is happening, the SERVER1
peer thread is not reading its socket & so could not receive any 'abort'
command from the TCPCLIENT. should it want to stop the download. To be
honest, Indy is a bit weak in this area because it does not provide any easy
way of waiting on both a blocking socket read *and* an event/semaphore
handle that could signal the arrival of another buffer to send off.

Rgds,
Martin










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.