View Full Version : Socket programming

December 10th, 2012, 07:11 AM
hi everyone, i just wanna know how to connect 2 computers with socket programming in c language. Both of computers are using ubuntu OS. thanks

December 10th, 2012, 08:25 AM
Google for 'POSIX socket API'.

December 10th, 2012, 09:22 AM
I know how to connect client and server in one computer which is running ubuntu OS. But I dun know how to connect in different computer. Pls help me... Thanks :)

December 10th, 2012, 09:25 AM
The best tutorial I found online is this one (http://beej.us/guide/bgnet/).
It teaches the latest IPv6 standard (with all the bells and whistles, including sockets) and it's slightly funny, which is good.

Other resources I found are typically either too small or too professorial and bloated, or outdated.

EDIT: to connect 2 different computers you need to know the other computer's IP and use it to create a socket to connect to it.

December 10th, 2012, 09:36 AM
But there is router between 2 computers. So IP address of both computers will be the same right?

December 10th, 2012, 10:20 AM
I don't know, but I suspect that from the perspective of your computer the other one will have 2 IP addresses, the local one (typically 192.x.x.x or other ones alike) and the public one, which is the one which all internet websites detect (http://whatismyipaddress.com/) when you visit them.

All I know is that the IP/http/dns/router/IP mask/whatever stacks are incredibly complex and you have to read entire books to clearly get the whole picture.

December 17th, 2012, 02:29 PM

December 19th, 2012, 07:12 AM
Threads merged. Please do not start multiple threads for the same question, it dilutes the community's ability to help.