title: getsockname returns a Error 22, Invalid argument
body: <p>We use IPV4 socket connection over UDP.</p>
  
  <pre><code> struct sockaddr_in   LocalSin;  
       int n_namelen ;
       memset( &amp;LocalSin, 0, sizeof(LocalSin) );
       LocalSin.sin_family = AF_INET;
       LocalSin.sin_port = htons(1050);
      socketS = socket(AF_INET, SOCK_DGRAM, 0);
       if ( bind(socketS, (struct sockaddr *)&amp;LocalSin, sizeof(struct sockaddr_in)) != RTCS_OK  )
            {
      //socket bind error
          }
  n_namelen = sizeof(struct sockaddr_in);
          if ( getsockname( socketS, (struct sockaddr *)&amp;LocalSin,(socklen_t *) &amp;n_namelen) != RTCS_OK)
            {
      //getsockname error
      }
  </code></pre>
  
  <p>Here socket function succeeds, also the bind succeeds, but , getsockname fails with error 22, occasionally(mostly), but succeeds few times.. The environment is Linux 3.0.35. Any suggestions?</p>
  
  <p>Note: the OS has both IPV6 and IPV4 enabled</p>
  
  <p>Note - Progress: the sizeof(struct sockaddr_in) comes as 16. Which can never be when we check its definition in the in.h . Any clue?</p>