title: Java sockets event driven
body: <p>I have a client that will connect to a server through a socket. After connecting every event that happens on the server will be sent to all registered clients.</p>
  
  <p>Every client should receive data related to the event. </p>
  
  <p>I just need to implement the client...meaning I need to connect to the server and receive the events' data.</p>
  
  <p>I was thinking on doing something like:</p>
  
  <pre><code>this.socket = new Socket(InetAddress.getByName(host),
  this.socket.connect(socket.getLocalSocketAddress(), SOCKET_TIMEOUT);
  </code></pre>
  
  <p>And then launch a thread which gets the <code>InputStream</code> of the socket in a while loop.</p>
  
  <p>But I don't know if this the best way to implement an event driven client through a socket.</p>
  
  <p>Is it?</p>