Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client-Server

 
Alan Jackson
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alan Jackson
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its gonna be using RMI
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic