|
Re: Socket Programming
|
Posted: Nov 22, 2005 6:05 AM
|
|
> > I want to use java socket programming to write a > program > > which enables client to use a printer connected to > > server machine. Is it possible ? If yes, how ? Please > Help > > me. > > Its definitely possible, I'm not exactly sure how to go > about > it though. However here is a long shot, anyone feel free > to > dip in. You will need to know what Messages the Server > requires and at what port, you will also need to know > what responses it gives, that's the starting point.
For example if you send a Get Request to Port 80 of a WebServer you get the index page in HTML format (if I'm not mistaken) Something like that.
E.g. Client Sends to port the Serialized Object with defined properties, or simply a string as indicated below -
// Send the String hello to port 545 on a configured // server. i.e. the client Object already has the // server it is sending to configured as a String // and has the Socket open at 545. client.send("hallo");
// The Server is expecting "hello" else it send you back //an error.
//server listens.
while(no_incoming_strings){
listenAtPort(545);
if(stringReceived){
if(receivedString.equals("hello")){
return ("OK I have started Printing");
// if using send "break" out of loop
}else{
// or send
return error;
}
}
}
So you would have to know what port the Computer is listening for the print Service at (that is the Server computer).
I think it should be something like that. Otherwise, just Google Cups if you're using Linux, I'm still trying top learn it so I can't tell you much about it.
> Anyone > want to add anything?? As I said that's a long shot on > my part.
|
|