We help IT Professionals succeed at work.

Java TCP socket stream communication

oggiemc
oggiemc asked
on
Hello all,

Ive been giving a college assignment in which we must use swing GUI and TCP sockets to develop a client/server network in which the client can send messages (of type object, not string) over the network to the server which will then be rendered on all logged on client GUIs. My question is what is the best way for the server to display the messages on client GUIs, is it to use the drawString() method? Im not sure about my options on how to render the received messages onto the client GUIs and so would like some opinions/discussion.

Thanks
Comment
Watch Question

Software Engineer
Commented:
Q: My question is what is the best way for the server to display the messages on client GUIs, is it to use the drawString() method?
A: It depends...

  For simplicity sake, you might want to at least start with simple text messages, and have the received text appended to the client text area.

  Things can get much more "interesting" when you want to do stuff like display images.  One way to do this might be to send some kind of meta-data with the object.  You might even want to use XML to identify the stuff being sent and received.  Then, the client could use XML parsing to decide how best to display the received object.

This sounds kind of fun.  ;-)
Awarded 2011
Awarded 2011
Commented:
Server would probably not draw directly on clients screen but it would send some response to the client - and based on that response
client java application wouild draw on the screen. At least taht seems to be the natural way of how client/server application would work.
Unless you just use client as terminal to the server - that would probably rtather happen not on java level.
HonorGodSoftware Engineer

Commented:
Thanks for the grade & points.

Good luck & have a great day.