title: C++ 64bit - Operation was attempted on object that is not a SOCKET
body: <p>I am new to socket programming and I was trying to ping a machine using socket programming. My code is compiled as a 64 bit platform.</p>
  
  <p>Here is the code that I am using:</p>
  
  <pre><code>SOCKET    rawSocket;
  struct    sockaddr_in saDest;
  struct timeval Timeout;
  fd_set readfds;
  struct addrinfo *result = NULL;
  struct addrinfo hints;
  DWORD  dwRetVal;
  
  rawSocket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
  memset(&amp;hints, 0, sizeof(hints));
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_family = AF_INET;
  
  dwRetVal = getaddrinfo(pstrHost, NULL, &amp;hints, &amp;result);
  
  saDest.sin_addr.s_addr = ((struct sockaddr_in *)(result-&gt;ai_addr))-&gt;sin_addr.s_addr;
  saDest.sin_family = AF_INET;
  saDest.sin_port = 0;
  
  FD_ZERO(&amp;readfds);
  FD_SET(rawSocket, &amp;readfds);
  
  Timeout.tv_sec = 5;
  Timeout.tv_usec = 0;
  
  select(1, &amp;readfds, NULL, NULL, &amp;Timeout);
  </code></pre>
  
  <p>As soon as I execute <code>select</code> call it returns with error: "An operation was attempted on something that is not a socket". And error code <code>select() error: 10038</code></p>
  
  <p>Any ideas on what could have been wrong?</p>
  
  <p><code>UPDATE 1</code>: I have just tried <code>connect</code> before making <code>select</code> call like below</p>
  
  <pre><code>dwRetValue = connect(rawSocket, (SOCKADDR *) &amp; saDest, sizeof(saDest));
  </code></pre>
  
  <p>and this call returning 0.  </p>