Next: 7 A modified client Up: GNUstep Distributed Objects Previous: 5.2 Accessing the remote

6 Putting them together

For the sake of completeness, here is the GNUmakefile:
include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = Server Client

Server_OBJC_FILES = Server.m
Client_OBJC_FILES = Client.m

include $(GNUSTEP_MAKEFILES)/tool.make
After you compile the two tools, you have definitely to play with them because it's real fun. Start the server:
./obj/Server
Now open another shell (on another machine on the same network if you are so lucky that you can play on the network), and start the client from there:
./obj/Client Client.m
this should display you the Client.m file, as fetched by the Server program.

On my machine it works so simply, immediately and nicely that it is even difficult to realize that the client has actually opened a network connection to the server, asked for the file, and the server has sent it back through the connection! To get more feeling of what is happening,you might want to modify the FileReader class in the server to display a log each time it sends a file:

@implementation FileReader
- (NSString *)getFile: (NSString *)fileName
{
  NSLog (@"A client asked for file %@", fileName);
  return [NSString stringWithContentsOfFile: fileName];
}
@end



2011-02-09