title: bind is not working in my C program
body: <p>This is the code which I wrote to create a socket and bind it to the address and port:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;strings.h&gt;
  #include &lt;netdb.h&gt;
  
  int main(int argc, char *argv[])
  {
      const char APPRESSMESSAGE[] = "APRESS,For Profesionals By Professional!\n";
      int SimpleSocket = 0;
      int SimplePort = 0;
      if (argc != 2)
      {
          fprintf(stderr, "USAGE: %s &lt;port&gt;\n", argv[0]);
          exit(1);
      }
      SimpleSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
      if (SimpleSocket == -1)
      {
          fprintf(stderr, "Could not create the socket !\n");
          exit(2);
      }
      else
      {
          fprintf(stdout, "socket created\n");
      }
      SimplePort = atoi(argv[1]);
      struct sockaddr_in SimpleServer;
      bzero(&amp;SimpleServer, sizeof(SimpleServer));
      SimpleServer.sin_family = AF_INET;
      SimpleServer.sin_addr.s_addr = htonl(INADDR_ANY);
      SimpleServer.sin_port = htons(SimplePort);
      int return_status;
      return_status = bind(SimpleSocket, (struct sockaddr *)&amp;SimpleServer, sizeof(SimpleServer));
      if (return_status == 0)
      {
          fprintf(stdout, "bind completed\n");
      }
      else
      {
          fprintf(stderr, "could not bind to socket\n");
          close(SimpleSocket);
          exit(1);
      }
      return 0;
  }
  </code></pre>
  
  <p>Here, I am expecting the output to be:</p>
  
  <pre><code>socket created
  bind completed.
  </code></pre>
  
  <p>But the result is "could not bind to socket".
  What can be the possible reason for this?</p>