The following is in c# - but it's about as simple as it gets.
Introduction to TCP client server in C#[
^]
Without a TCPListener you have to actively poll the server for data, on its own, the TCPClient does not listen for incomming requests.
Use something like
ThreadPool[
^] to poll data from the server asynchronously, and remember to synchronize access from the worker thread with the UI thread -
Another way to Invoke UI from a Worker Thread[
^].
If you don't use threads your client will appear to hang while polling the server. Another option is to poll using asynch io - but that's usually considered harder to implement correctly - good luck :)
Update
Hopefully this article will guide you towards creating a satisfying solution:
A Chat Application Using Asynchronous TCP Sockets[
^]
Regards
Espen Harlinn