jesuashok: Perhaps I should have mentioned earlier that I am working under Windows. Apparently, doing non-blocking socket IO under Windows is a little problematic, as discussed here. The polling solution does work well though and hopefully won't consume too much resources if I sleep for a short time (since I want to act immediately on incoming data) in between polls.
merlyn: I will take a look at POE and see how it can help me.
MonkE: I do understand that much more is needed for the server, but the code I posted was just a simplified exerpt from the client program. Thanks though!
<code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>