📄 ipsock.h
字号:
The port number as defined by the object instance construction or the #PIPSocket::SetPort()# function. @return TRUE if the channel was successfully connected to the remote host. */ virtual BOOL Connect( const PString & address /// Address of remote machine to connect to. ); virtual BOOL Connect( const Address & addr /// Address of remote machine to connect to. ); virtual BOOL Connect( WORD localPort, /// Local port number for connection const Address & addr /// Address of remote machine to connect to. ); /** Listen on a socket for a remote host on the specified port number. This may be used for server based applications. A "connecting" socket begins a connection by initiating a connection to this socket. An active socket of this type is then used to generate other "accepting" sockets which establish a two way communications channel with the "connecting" socket. If the #port# parameter is zero then the port number as defined by the object instance construction or the #PIPSocket::SetPort()# function. For the UDP protocol, the #queueSize# parameter is ignored. @return TRUE if the channel was successfully opened. */ virtual BOOL Listen( unsigned queueSize = 5, /// Number of pending accepts that may be queued. WORD port = 0, /// Port number to use for the connection. Reusability reuse = AddressIsExclusive /// Can/Cant listen more than once. ); virtual BOOL Listen( const Address & bind, /// Local interface address to bind to. unsigned queueSize = 5, /// Number of pending accepts that may be queued. WORD port = 0, /// Port number to use for the connection. Reusability reuse = AddressIsExclusive /// Can/Can't listen more than once. ); // New functions for class /** Get the "official" host name for the host specified or if none, the host this process is running on. The host may be specified as an IP number or a hostname alias and is resolved to the canonical form. @return Name of the host or IP number of host. */ static PString GetHostName(); static PString GetHostName( const PString & hostname /// Hosts IP address to get name for ); static PString GetHostName( const Address & addr /// Hosts IP address to get name for ); /** Get the Internet Protocol address for the specified host, or if none specified, for the host this process is running on. @return TRUE if the IP number was returned. */ static BOOL GetHostAddress( Address & addr /// Variable to receive hosts IP address ); static BOOL GetHostAddress( const PString & hostname, /* Name of host to get address for. This may be either a domain name or an IP number in "dot" format. */ Address & addr /// Variable to receive hosts IP address ); /** Get the alias host names for the specified host. This includes all DNS names, CNAMEs, names in the local hosts file and IP numbers (as "dot" format strings) for the host. @return array of strings for each alias for the host. */ static PStringArray GetHostAliases( const PString & hostname /* Name of host to get address for. This may be either a domain name or an IP number in "dot" format. */ ); static PStringArray GetHostAliases( const Address & addr /// Hosts IP address /* Name of host to get address for. This may be either a domain name or an IP number in "dot" format. */ ); /** Determine if the specified host is actually the local machine. This can be any of the host aliases or multi-homed IP numbers or even the special number 127.0.0.1 for the loopback device. @return TRUE if the host is the local machine. */ static BOOL IsLocalHost( const PString & hostname /* Name of host to get address for. This may be either a domain name or an IP number in "dot" format. */ ); /** Get the Internet Protocol address for the local host. @return TRUE if the IP number was returned. */ virtual BOOL GetLocalAddress( Address & addr /// Variable to receive hosts IP address ); virtual BOOL GetLocalAddress( Address & addr, /// Variable to receive peer hosts IP address WORD & port /// Variable to receive peer hosts port number ); /** Get the Internet Protocol address for the peer host the socket is connected to. @return TRUE if the IP number was returned. */ virtual BOOL GetPeerAddress( Address & addr /// Variable to receive hosts IP address ); virtual BOOL GetPeerAddress( Address & addr, /// Variable to receive peer hosts IP address WORD & port /// Variable to receive peer hosts port number ); /** Get the host name for the local host. @return Name of the host, or an empty string if an error occurs. */ PString GetLocalHostName(); /** Get the host name for the peer host the socket is connected to. @return Name of the host, or an empty string if an error occurs. */ PString GetPeerHostName(); /** Clear the name (DNS) cache. */ static void ClearNameCache(); /** Get the IP address that is being used as the gateway, that is, the computer that packets on the default route will be sent. The string returned may be used in the Connect() function to open that interface. Note that the driver does not need to be open for this function to work. @return TRUE if there was a gateway. */ static BOOL GetGatewayAddress( Address & addr /// Variable to receive the IP address. ); /** Get the name for the interface that is being used as the gateway, that is, the interface that packets on the default route will be sent. The string returned may be used in the Connect() function to open that interface. Note that the driver does not need to be open for this function to work. @return String name of the gateway device, or empty string if there is none. */ static PString GetGatewayInterface(); /** Describes a route table entry */ class RouteEntry : public PObject { PCLASSINFO(RouteEntry, PObject); public: /// create a route table entry from an IP address RouteEntry(const Address & addr) : network(addr) { } /// Get the network address associated with the route table entry Address GetNetwork() const { return network; } /// Get the network address mask associated with the route table entry Address GetNetMask() const { return net_mask; } /// Get the default gateway address associated with the route table entry Address GetDestination() const { return destination; } /// Get the network address name associated with the route table entry const PString & GetInterface() const { return interfaceName; } /// Get the network metric associated with the route table entry long GetMetric() const { return metric; } protected: Address network; Address net_mask; Address destination; PString interfaceName; long metric; friend class PIPSocket; }; PLIST(RouteTable, RouteEntry); /** Get the systems route table. @return TRUE if the route table is returned, FALSE if an error occurs. */ static BOOL GetRouteTable( RouteTable & table /// Route table ); /** Describes an interface table entry */ class InterfaceEntry : public PObject { PCLASSINFO(InterfaceEntry, PObject) public: /// create an interface entry from a name, IP addr and MAC addr InterfaceEntry(const PString & _name, const Address & _addr, const PString & _macAddr) : name(_name), ipAddr(_addr), macAddr(_macAddr) { } /// Get the name of the interface PString GetName() const { return name; } /// Get the address associated with the interface Address GetAddress() const { return ipAddr; } /// Get the MAC address associate with the interface PString GetMACAddress() const { return macAddr; } protected: PString name; Address ipAddr; PString macAddr; }; PLIST(InterfaceTable, InterfaceEntry); /** Get a list of all interfaces @return TRUE if the interface table is returned, FALSE if an error occurs. */ static BOOL GetInterfaceTable( InterfaceTable & table /// interface table );#ifdef DOC_PLUS_PLUS};#endif// Class declaration continued in platform specific header file ///////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -