title: How to Create a TCP socket connect using C to a predefined port
body: <p>I have a very simple question. I want to test whether a particular port is currently under use or not. For this, I want to bind a TCP socket to the port, if the connection is refused means the port is in use and if not that mean the port is free.</p>
  
  <p>Can someone please tell me how can I write the TCP socket code in C? I am on a solaris platform.</p>
  
  <p>I know its very basic. But I appreciate your help. Thanks in advance.</p>