title: gethostbyname and portno as an array
body: <p>I'm working on server-client application in IDE Momentics Tool.<br>
  This is the server part:</p>
  
  <pre><code>int sockfd, portno, a;
  char *IP[16];
  
  int server_to_client(struct AllPack allmess)
  {
       int portno;
       struct sockaddr_in serv_addr;
       struct hostent *server;
       if (a &lt; 2) 
       {
           fprintf(stderr,"ERROR, no IP and port provided\n");
           exit(1);
       }
       portno = atoi(IP[2]);
  
       sockfd = socket(AF_INET, SOCK_DGRAM, 0);
       if (sockfd &lt; 0) error ("ERROR opening socket");
       {
           server = gethostbyname(IP[1]);
       }
       if (server == NULL)
       {
           fprintf(stderr, "ERROR, no such host\n");
           exit(0);
       }
  
       bzero((char *) &amp;serv_addr, sizeof(serv_addr));
       serv_addr.sin_family = AF_INET;
       bcopy((char *) server -&gt; h_addr, (char *)&amp;serv_addr.sin_addr.s_addr, server -&gt; h_length);
       serv_addr.sin_port = htons(portno);
       if (connect(sockfd, (struct sockaddr *)&amp;serv_addr, sizeof(serv_addr)) &lt; 0) error ("ERROR connecting");
  
       int n = write(sockfd, &amp;allmess, sizeof(allmess));
       if (n &lt; 0) error ("ERROR writing socket");
       close(sockfd);
       return (EXIT_SUCCESS);
  }
  
  int main(int argc, char *argv[])
  {
      a = argc;
  
      for(int i = 0; i &lt; a; i++)
      {
          IP[i] = argv[i];
      }
      server_to_client(allmess);
  
      return (EXIT_SUCCESS);
  }
  </code></pre>
  
  <p>I'm trying to make <code>portno = atoi(IP[2]);</code> an array of ports and <code>server = gethostbyname(IP[1]);</code> an array of IP-addresses. </p>
  
  <p>I'm starting my server part like this:</p>
  
  <pre><code>/home/Server 192.168.0.21 70003 192.168.0.22 70004
  </code></pre>
  
  <p>so I have to send data to several IP through several ports at the same time?</p>