Socket programming

Suppose i am writing a C program which is going to use Socket calls. I want to use a Unix port for my Socket.

How can i determine a port which is not already in use?

netstat -an will show you what ports are in use on the local and remote machines (if that port is establishing a connection to a remote machine) as well as the protocol running over that port for that connection and IP address information.

Regards.