> Yes.
>>> Hello
>>>
[quoted text clipped - 14 lines]
> saves having to open a listening port on the client side, something that
> can hurt when it bangs into a firewall.
Right, if the client-server protocol is a "take turns to speak" type of
deal, you can save yourself some headaches using the method Lew proposed.
However, if the server can send data to the client at any moment in time,
having a seperate thread sitting around and listening for incoming data
sounds like a good idea to me.
In the tutorial I linked to, there's an example of the client opening a
socket to the server (thus bypassing most firewall issues), and then using
that socket for both input and output.
- Oliver
Angus - 25 Nov 2006 18:53 GMT
> >>> Hello
> >>>
[quoted text clipped - 26 lines]
>
> - Oliver
The approach which I am trying out at the moment is for my applet to launch
a separate thread to handle the socket communication. The server can send
information at any moment in time as you say.
But if I click on say a button in the applet, the button needs to send some
command to the server. How do I send this command to the separate thread I
have spun off?
Sorry this is probably a really basic Java question but I am a beginner. Do
I need to somehow post a message to the thread spun off?
Angus
Oliver Wong - 27 Nov 2006 17:09 GMT
> The approach which I am trying out at the moment is for my applet to
> launch
[quoted text clipped - 10 lines]
> Do
> I need to somehow post a message to the thread spun off?
Lookup the "Producer/Consumer" problem. Your applet thread is the
producer, producing messages which it will put onto a message-queue. The
socket-handling thread is the consumer, removing messages from that queue,
and sending it out to the server.
- Oliver