title: 'Bad address' when doing sendto-call to the sockaddr* retrieved by recvfrom
body: <pre><code>    struct sockaddr_in  addrSenderOfVideo
      struct sockaddr_in   client_addr;     // Client Internet address
      char* buffer = new char[2];
      int sizeOfBuffer=1050;
      int clientfd;
      char* bufferWithPacketData = new char[sizeOfBuffer];
      extern int                  client_s;        // Client socket 
  
      if (client_s &lt; 0)
            {
              printf("*** ERROR - socket() failed \n");
            }
  
             //Client address.
        client_addr.sin_family = AF_INET;
        client_addr.sin_addr.s_addr = htonl(INADDR_ANY); // IP address to use
        client_addr.sin_port = htons(portNumClient); 
  
      clientfd = bind(client_s,(const sockaddr*) &amp;client_addr, sizeof(client_addr));
      fprintf (stderr, "inside of listen for new packet&lt;; clientfd is %d",clientfd);
  
        if (clientfd &lt; 0) 
          {
          fprintf (stderr, "WARNING -1 doing BIND!");
  
          }
  
  
      int n = recvfrom (client_s, bufferWithPacketData, sizeOfBuffer, 0,(struct sockaddr*)&amp;addrSenderOfVideo, &amp;fromlen);
  
     retcode = sendto(client_s, buffer,  symbol_size, 0,
            (struct sockaddr *)&amp;addrSenderOfVideo, sizeof(addrSenderOfVideo) );
  </code></pre>
  
  <p>When sendto is called, the error '9errno is Bad address' is printed out.
  What is the cause of this and how do I resolve this?</p>
  
  <p>The data is received from the sender in the function recvfrom, and <code>addrSenderOfVideo</code> contains both a port and an ip-number.
  The sender has the ip '127.0.0.1' and this is also the ip that is contained in <code>addrSenderOfVideo</code>.</p>