title: How to make a basic instant messaging program in pure Java
body: <p><strong>Reinstating this question with a bounty!</strong> I need an example that <strong>stays online</strong>, like a real instant messenger! It needs to <strong>always be ready to receive or send a message</strong> to an arbitrary address over an arbitrary port, using TCP. <strong>The program must not quit after sending/receiving a message.</strong></p>
  
  <blockquote>
    <p>Bounty goes to whoever can give the best example of a real, usable instant messenger.</p>
  </blockquote>
  
  <hr>
  
  <p>Looking online, all resources I found are either <a href="http://www.ehow.com/how_7654082_build-instant-messenger-using-java.html" rel="noreferrer">useless tutorials</a>, <a href="http://www.dreamincode.net/forums/topic/141059-java-instant-messenger-program-help/" rel="noreferrer">dead threads</a>, <a href="http://ashishmyles.com/tutorials/tcpchat/index.html" rel="noreferrer">dead tutorials</a>, <a href="http://pirate.shu.edu/~wachsmut/Teaching/CSAS2214/Virtual/Lectures/chat-client-server.html" rel="noreferrer">ancient examples</a>, or tell the programmer to use external APIs. <strong>How can I create a basic instant messenger from the ground up, only using Java SE?</strong></p>
  
  <p>There must be a way to do this, and <strong>some sample code would be appreciated</strong>. It only needs to perform the simplest tasks: Check if a compatible client is online on another computer (IP will be provided by the user) and send a TCP packet to that client, which will receive and display its contents.</p>