if someone can provide an example (simple ones ) or even just steps ( like , create subject , connect to host like that )on how to achieve that , it would be really appreciated guys.
I guess all those complete programs are very difficult to decipher. I understand you like a small simple project which shows you how to setup a TCP connection on both end.
I threw something together which does just that (see project attached). For Windows at the moment but converting it to Linux shouldn't be a problem.
First you need a thread for listening for an incoming connection (click the Listen button on one computer). I used a button because for testing on my computer I just used one PC with a connection to 127.0.0.1 (localhost). You would have this on different computers and you could start Listen on both computers without a problem.
On one of the computers you can click Connect. A connection is made to the given-IP. (Of course that computer needs to be "listening".)
Then, after the listening thread sees an incoming message, it signals the main form to create a TCPBlockSocket. That form, in turn, creates a Receiving thread. I tried receiving via a TTimer but that just slows things down. When the receiving thread receives a string it signals the main form to add it to the memo. For sending a string you can just use the just created TTCPBlockSocket. The receiving thread also creates it's own TCPBlockSocket with the socket from the main form.
It kind of looks complex with those two threads but the listening thread is only used for listening for an incoming connection and the receiving thread is used for receiving in the background (otherwise your program is constantly checking for incoming traffic).
(b.t.w. I added blcksock to my project but maybe it's in a different path than yours so you might need to change it)