Hello azarakhsh,

Try these links:

Lesson: All About Sockets (The Java™ Tutorials > Custom Networking)

Java TCP Sockets and Swing Tutorial