Hi, I'm using tomcat passing servlet page. There has a function let user download file from server. Since my client don't want to see the 'save as' window and don't want user change file name, I have to make this thing work as a background job. I think I may get this from socket. Since I never use socket before, I really need some help about the idea of how to do it. Thanks. Jim
Laudney Ren
Ranch Hand
Joined: Jan 06, 2002
Posts: 111
posted
0
Well, using Socket really requires some knowledge. A brief procedure is described here: Server creates a ServerSocket and ueses accept(0 to listen on a specific port. Accept() returns the established Socket. Call Socket 's getOutputStream and write to the stream. Client calls Socket's getInputStream and reads from the stream. Well, I describe the process quite briefly here. For authoritive information about Java net programming, refer to Elliotte Harold's Java Network Programming or go to his website http://metalab.unc.edu/javafaq
" Veni, vidi, vici "<br />" I came, I saw, I conquered "
Jim Wang
Ranch Hand
Joined: Oct 04, 2001
Posts: 41
posted
0
Thanks Laudney, I read some documents about socket and it same as you said. I got a question here, if I'm going to send a file to client by socket, is that mean I also need to put a application on client side to create the connection for download file? Jim
Laudney Ren
Ranch Hand
Joined: Jan 06, 2002
Posts: 111
posted
0
Well, sometimes the client can also be the server. Method 1: on the client side, establish a socke to the server. Method 1: make your client a server, listen on a specific port and the server (now a client) establish the socket (or connetion) actively. Anyway, you need coding on both sides.