title: TCP recvfrom() doesn't store 'from'
body: <p>I'm making a server program using TCP and I want to get the IP adress of the sender of the message I just received. Here's my code:</p>
  
  <pre><code>case FD_READ:
  {    //Incoming data; get ready to receive
      char buffer[DEFAULT_BUFLEN];
      int bytes_received; 
      memset(buffer, '\0', sizeof(buffer));
  
      struct sockaddr_in recvIn;
      int recv_length = sizeof(struct sockaddr);
  
      memset((void *)&amp;recvIn, '\0', recv_length);
  
      bytes_received = recvfrom(wParam, buffer, DEFAULT_BUFLEN, 0, (struct sockaddr *)&amp;recvIn, &amp;recv_length);
      cout &lt;&lt; inet_ntoa(recvIn.sin_addr) &lt;&lt; "\n";
  
      break;
  }
  </code></pre>
  
  <p>So I'm using Windows messages to see if I should check for packets. Receiving data works, I can read it and everything. But the recvIn variable doesn't get altered by recvfrom. So when I do the cout &lt;&lt; inet_ntoa(recvIn.sin_addr) &lt;&lt; "\n" it writes "0.0.0.0". I've googled this problem and most other people that had this problem forgot to initialize the recv_length. But I'm pretty sure I did that correctly here. Can anyone see what I'm doing wrong? Or do I need to change something with the data that's being sent? Does the incoming data maybe not have the IP adress. Which is something I highly doubt, because I'm using TCP.</p>
  
  <p>Thank you for you time, I hope I can get this solved!</p>