Logo Search packages:      
Sourcecode: pwlib version File versions

BOOL PSocksUDPSocket::ReadFrom ( void *  buf,
PINDEX  len,
Address addr,
WORD &  port 
) [virtual]

Read a datagram from a remote computer.

TRUE if any bytes were sucessfully read.

Reimplemented from PIPDatagramSocket.

Definition at line 683 of file socks.cxx.

References PIPSocket::GetHostAddress(), PChannel::Miscellaneous, and PIPDatagramSocket::ReadFrom().

  PBYTEArray newbuf(len+262);
  Address rx_addr;
  WORD rx_port;
  if (!PUDPSocket::ReadFrom(newbuf.GetPointer(), newbuf.GetSize(), rx_addr, rx_port))
    return FALSE;

  if (rx_addr != serverAddress || rx_port != serverPort)
    return FALSE;

  PINDEX port_pos;
  switch (newbuf[3]) {
      if (!PIPSocket::GetHostAddress(PString((const char *)&newbuf[5], (PINDEX)newbuf[4]), addr))
        return FALSE;

      port_pos = newbuf[4]+5;

    case SOCKS_ADDR_IPV4 :
      memcpy(&addr, &newbuf[4], 4);
      port_pos = 4;

    default :
      SetErrorCodes(PChannel::Miscellaneous, EINVAL);
      return FALSE;

  port = (WORD)((newbuf[port_pos] << 8)|newbuf[port_pos+1]);
  memcpy(buf, &newbuf[port_pos+2], len);

  return TRUE;

Generated by  Doxygen 1.6.0   Back to index