aspose file tools*
The moose likes Distributed Java and the fly likes Client-Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Client-Server" Watch "Client-Server" New topic
Author

Client-Server

Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
Im working on a client server application, and what Im gonna do is have the client use a simple case statement.

When 2 is the chosen option, I need to read in a filename (as a string) via the keyboard, which is easily enough done. How would I go about passing that filename to the server, then having the server pass back some kind of response?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi Alan,

Well, depends on what networking technology you're using. Raw sockets? HTTP? RMI? CORBA? If HTTP: forms? raw POST? SOAP? Something else? There are a lot of choices, and every one has its place. Let me know what you're thinking, and we'll move this thread to the appropriate forum for that technology. Or if you have no idea, let's talk about your requirements.


[Jess in Action][AskingGoodQuestions]
Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
Its gonna be using RMI
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

OK, I'm going to move this to the Distributed Java forum, where we will continue this conversation.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

So your RMI server object needs a method something like

String processFile(String)

and the implementation just has to use the filename (presumably you're dealing with the filenames-having-different-meanings-on-different-machines issue) and return the result. The client then just calls this method to get the result.

I make it sound so easy, that I'm obviously either missing something, or there's some part of this I can help you with. Let me know.
Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
So my server has the method processFile(), so how do I pass the filename? Im thinking the processFile() should run like:

client:
read in filename and save to variable
pass to server
wait for server to pass back string

server:
listen for client to send filename
open file
pass back "this file contains...."

I might be asking a really stupid question, but how do I actually pass the file name from the client to the server?
[ November 04, 2004: Message edited by: Alan Jackson ]
jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
I'm not too sure using RMI. However if you were using sockets, to send the filename one direction would be simple like writing the filename to a file on disk.

Very simple.

To read the contents of that file in the other direction would also be just like reading from a file on disk.

Take a look at any introductory client/server application and you will see what I mean.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

It's very simple using RMI -- simpler than using raw sockets, for sure.

Your processFile() method should take a String argument which is the name of the file. When the client calls the method, it should pass the filename as the argument. That's all.

Sun's RMI Tutorial is pretty helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Client-Server