J
John_Woo
Hi,
Same socket server, communicates with different multi socket clients
some of which send to
socket a java object, and others send just a DataOutputStream, ex
some clients:
DataOutputStream os = null;
os = new DataOutputStream(smtpSocket.getOutputStream());
String msg = (new BufferedReader( new
InputStreamReader(System.in)).readLine())+"\n";
if (msg!=null) os.writeBytes(msg);
other clients:
ObjectOutputStream oo = null;
....
oo.writeObject(new MyObject());
I'm wondering, how does the server know what type the inputStream sent
from client is?
if that's of type
BufferedReader is;
is = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
then it's easy to print out or easy to send back a string.
if that's of customized Object type, then the server has something else
to do/respond.
Any idea?
Same socket server, communicates with different multi socket clients
some of which send to
socket a java object, and others send just a DataOutputStream, ex
some clients:
DataOutputStream os = null;
os = new DataOutputStream(smtpSocket.getOutputStream());
String msg = (new BufferedReader( new
InputStreamReader(System.in)).readLine())+"\n";
if (msg!=null) os.writeBytes(msg);
other clients:
ObjectOutputStream oo = null;
....
oo.writeObject(new MyObject());
I'm wondering, how does the server know what type the inputStream sent
from client is?
if that's of type
BufferedReader is;
is = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
then it's easy to print out or easy to send back a string.
if that's of customized Object type, then the server has something else
to do/respond.
Any idea?