title: Connection Refused on Recv(), while send seems to work fine
body: <p>I am trying to create a connection to a server/port that I'm provided - Upon making the connection, I am able to send it ping packets( at least I think I am able to, since send() seems to return the correct number of bytes), but when I try to recv() right after, the call fails saying</p>
  
  <pre><code>"Error on Receiving .. Connection Refused"  
  </code></pre>
  
  <p>Any ideas on why the send would not be giving an error, but recv would ? This following is the part of code causing my failure -it's running on it's own thread. The TCP connection was made on another thread, and that socket descriptor was passed to this one(it's called m_sockfd below). </p>
  
  <pre><code>void ConnectionManager::operator()()
  {
  
    int rc = 0, numBytes=0 ; 
    char reply[256] ; 
  
    // Send a ping
    char PingPacket[23] ; 
    PreparePingPacket(PingPacket) ; 
    numBytes = send(m_sockfd,PingPacket,23,0); 
    if(numBytes == -1)
    {
      fprintf(stderr, "Error on Sending Ping .. \n") ;   
      return ; 
    }
    if(numBytes &lt; 23)
    {
      fprintf(stderr, "Didn't send the whole Ping Request .. %d \n", numBytes) ;  
    }
  
    numBytes = recv(m_sockfd, reply, 256, 0) ; 
  
    if(numBytes == -1)
    {
      fprintf(stderr, "Error on Receiving .. %s \n", strerror(errno)) ;   
      return ; 
    }
  
    ParsePacket(reply, rc) ; 
  }
  </code></pre>
  
  <p>I can paste my code which does the actual connection, but I'd figure if it had the error, then the send would have never gone through to begin with ?</p>
  
  <p>Thanks for reading  - any help appreciated !</p>