title: FTP, passive mode. Can't assign requested address
body: <p>I cannot to connect to data port. I am able to connect to 21 command port, send username and password. Then I send <code>PASV\r\n</code>. I get response and compute data port <code>A * 256 + B = new_port</code>. 
  Problem is that I cannot connect to this port. 
  For creating socket I am using <code>createRemoteConnection()</code> function. That is used twice, first time for command port and I pass there <code>new_port</code> and then I call it once again. 
  Could you help me please? Thank you.</p>
  
  <pre><code>PASV
  227 Entering Passive Mode (80,251,0,59,158,36).
  A: 158
  B: 36
  Port: 40484
  Creating socket...
  Socket created
  connect failed. Error: Can't assign requested address
  </code></pre>
  
  <p>-</p>
  
  <pre><code>int createRemoteConnection(Arguments &amp;arguments,int cmd) {
  int sock;
  struct sockaddr_in server;
  if (DEBUG) {
      puts("Creating socket...");
  }
  
  //Create socket
  sock = socket(AF_INET , SOCK_STREAM , 0);
  if (sock == -1)
  {
      fputs("Could not create socket.\n",stderr);
      exit(1);
  }
  
  if (DEBUG) {
      puts("Socket created");
  }
  
  char ip[100];
  struct hostent *he;
  struct in_addr **addr_list;
  
  if ((he = gethostbyname(arguments.hostname)) == NULL) {
      herror("gethostbyname");
      exit(1);
  }
  
  addr_list = (struct in_addr **) he-&gt;h_addr_list;
  
  for (int i = 0; addr_list[i] != NULL; i++) {
      strcpy(ip, inet_ntoa(*addr_list[i]));
  }
  
  server.sin_addr.s_addr = inet_addr(ip);
  server.sin_family = AF_INET;
  server.sin_port = htons(cmd);
  
  //Connect to remote server
  if (connect(sock , (struct sockaddr *)&amp;server , sizeof(server)) &lt; 0)
  {
      perror("connect failed. Error");
      exit(1);
  }
  
  if (DEBUG) {
      puts("Connected\n");
  }
  
  return sock;
  }
  </code></pre>