title: Passing pointer to SOCKADDR_IN and SOCKET in a function
body: <p>I have a function <em>createServerSocket()</em>. This function can be accessed by multiple threads for creating their sockets. </p>
  
  <p>I want each thread to pass three arguments, a <em>socketIdentifier</em>, *sockaddr_in* and specific <em>port number</em> to <em>createrServerSocket()</em> function, so that each thread has a unique socket.</p>
  
  <p>For this, I am passing <em>socketIdentifier</em>, *sockaddr_in* and specific <em>port number</em> to createrServerSocket() function as pointers so that socketIdentifier and socket created must be accessable inside thread. </p>
  
  <p>Below is my code snippet:</p>
  
  <pre><code>VOID createServerSocket(SOCKADDR_IN *socket, SOCKET *socketIdentifier, int PORT)
  {
  
     //Socket Binding//
     WSADATA wsa; 
  
     //Initialise winsock//
     if (WSAStartup(MAKEWORD(2,2),&amp;wsa) != 0)
        {
           exit(EXIT_FAILURE);
        }
  
     //Create a socket//
     if((*socketIdentifier = socket(AF_INET , SOCK_DGRAM , 0 )) == INVALID_SOCKET)
        {                 
           MessageBox(NULL,
                      "Socket not Created",
                      "Failure :(",
                      MB_ICONINFORMATION);
           exit(EXIT_FAILURE);
        }
     //Socket Created//
  
     //Prepare the sockaddr_in structure//
     *socket.sin_family = AF_INET;
     *socket.sin_addr.s_addr = INADDR_ANY;
     *socket.sin_port = htons( PORT );
  
     //Bind//
     if( bind(socketIdentifier ,(struct sockaddr *)&amp;socket , sizeof(socket)) == SOCKET_ERROR)
        {             
           MessageBox(NULL,
                      "Bind Failed",
                      "Failure :(",
                      MB_ICONINFORMATION);
           exit(EXIT_FAILURE);
        }
     //Else Bind Done//
     MessageBox(NULL,
                "Bind Done",
                "SUCCESS :)",
                MB_ICONINFORMATION);
  
  }
  </code></pre>
  
  <p>Here is the calling function:</p>
  
  <pre><code>DWORD WINAPI threadProc(LPVOID param)
  {
      SOCKADDR_IN socket;
      SOCKET socketIdentifier;
      createServerSocket(*socket,*socketIdentifier,8888); //Create a socket with a socketIdentifier and bind()ed to PORT#8888.
          //Do something at this socket
          Return TRUE;
  }
  </code></pre>
  
  <p>These are the errors that I get:</p>
  
  <blockquote>
    <p>error C2064: term does not evaluate to a function taking 3 arguments<br>
    error C2228: left of '.sin_family' must have class/struct/union 
    error C2228: left of '.sin_addr' must have class/struct/union<br>
    error C2228: left of '.S_un' must have class/struct/union<br>
    error C2228: left of '.S_addr' must have class/struct/union 
    error C2228: left of '.sin_port' must have class/struct/union<br>
    error C2070: ''unknown-type'': illegal sizeof operand   </p>
  </blockquote>
  
  <p><strong>Line:</strong>
      if((*socketIdentifier = socket(AF_INET , SOCK_DGRAM , 0 )) == INVALID_SOCKET)</p>
  
  <p><strong>Error:</strong>
  <em>error C2064: term does not evaluate to a function taking 3 arguments</em></p>