Hey everyone,
I am facing an implementaton issue here ... hopefully someone can give me a hand ..

So I am implementing a client-server communication, where the server has to act as a print server. In other words, the client simulates to be next to a printer and can send a file to be printed, can check whats on the queue to be printed, can prioritize the queue etc ...

So far, I have a class Client and a class Server. The client can connect to the server using sockets, says "hi", receives the message back and disconnects ..

I also have a class Printer, which has few fields and methods such as String name, and getters/setters, it has a queue etc, nothing out of ordinary.

Now I started designing the GUI for the client and it is pretty much done, has buttons and text area where information will be displayed such as printer status, whats on queue etc.

Initially when the server is made, it creates a list of printers, from which the user can select which to use ...
Now, the problem that I am facing is I want to ask for the list from the client GUI, but I am confused(haven't slept in very long time so this must be a factor! :D) how can I actually do that? Like, I can click the button on the gui, but I have no idea what the server should expect to receive in order to return back the list of printers, do I need to have a switch statement with all possible inputs? This sound very inefficient:o What I really need is like an instance of the server to call a print all available printers but if I have instance of the server on my client side, then it won't really be a network communication inbetween ..

I hope you understand what I mean, Thanks in advance!

Recommended Answers

All 4 Replies

Java RMI would do that. It provides a version of the server's interface at the client end. Have a look at it, but be aware that it's pretty complicated and the learning curve is steep.
You may find it a lot easier to build you own simple protocol where the client sends one of a limited number of requests and the server replies as appropriate.

Hello James,
so I'd have to implement the entire thing in java rmi? :s

Like I said, RMI will do it, but it's hard
Writing your own little command handler is much easier.

Thank you james, I'll see what I can do .. but definitely not happy on my choices ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.