Greetings, Jackolim:
Have you investigated Datasocket? It can save you most of the "joy" of trying to write raw socket applications, and yet you maintain most of the functionality you are likely looking for. Also, there's no reason you can't use Datasocket to have an application "talk to itself" as well, it doesn't require separate client and server machines.
Look for datasocket examples in the help files for a good start.
Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705