📄 ipsock.h
字号:
/* * ipsock.h * * Internet Protocol socket I/O channel class. * * Portable Windows Library * * Copyright (c) 1993-1998 Equivalence Pty. Ltd. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is Portable Windows Library. * * The Initial Developer of the Original Code is Equivalence Pty. Ltd. * * Portions are Copyright (C) 1993 Free Software Foundation, Inc. * All Rights Reserved. * * Contributor(s): ______________________________________. * * $Log: ipsock.h,v $ * Revision 1.43 2000/06/26 11:17:19 robertj * Nucleus++ port (incomplete). * * Revision 1.42 1999/09/10 04:35:42 robertj * Added Windows version of PIPSocket::GetInterfaceTable() function. * * Revision 1.41 1999/09/10 02:31:42 craigs * Added interface table routines * * Revision 1.40 1999/08/30 02:21:03 robertj * Added ability to listen to specific interfaces for IP sockets. * * Revision 1.39 1999/08/08 09:04:01 robertj * Added operator>> for PIPSocket::Address class. * * Revision 1.38 1999/03/09 02:59:50 robertj * Changed comments to doc++ compatible documentation. * * Revision 1.37 1999/02/23 07:19:22 robertj * Added [] operator PIPSocket::Address to get the bytes out of an IP address. * * Revision 1.36 1999/02/16 08:12:00 robertj * MSVC 6.0 compatibility changes. * * Revision 1.35 1998/12/21 07:22:50 robertj * Virtualised functions for SOCKS support. * * Revision 1.34 1998/12/18 04:34:14 robertj * PPC Linux GNU C compatibility. * * Revision 1.33 1998/11/30 08:57:32 robertj * New directory structure * * Revision 1.32 1998/11/22 11:30:08 robertj * Check route table function to get a list * * Revision 1.31 1998/11/19 05:18:22 robertj * Added route table manipulation functions to PIPSocket class. * * Revision 1.30 1998/09/23 06:20:45 robertj * Added open source copyright license. * * Revision 1.29 1997/12/11 10:28:57 robertj * Added operators for IP address to DWORD conversions. * * Revision 1.28 1996/12/17 11:08:05 robertj * Added DNS name cache clear command. * * Revision 1.27 1996/11/30 12:10:00 robertj * Added Connect() variant so can set the local port number on link. * * Revision 1.26 1996/11/16 10:48:49 robertj * Fixed missing const in PIPSocket::Address stream output operator.. * * Revision 1.25 1996/11/04 03:40:54 robertj * Moved address printer from inline to source. * * Revision 1.24 1996/09/14 13:09:21 robertj * Major upgrade: * rearranged sockets to help support IPX. * added indirect channel class and moved all protocols to descend from it, * separating the protocol from the low level byte transport. * * Revision 1.23 1996/08/25 09:33:55 robertj * Added function to detect "local" host name. * * Revision 1.22 1996/03/26 00:51:13 robertj * Added GetLocalAddress() variant that returns port number as well. * * Revision 1.21 1996/03/16 04:41:30 robertj * Changed all the get host name and get host address functions to be more consistent. * * Revision 1.20 1996/03/03 07:37:56 robertj * Added Reusability clause to the Listen() function on sockets. * * Revision 1.19 1996/02/25 03:00:31 robertj * Added operator<< to PIPSocket::Address. * Moved some socket functions to platform dependent code. * * Revision 1.18 1996/02/08 12:11:19 robertj * Added GetPeerAddress that returns a port. * * Revision 1.17 1996/01/28 14:07:31 robertj * Changed service parameter to PString for ease of use in GetPortByService function * Fixed up comments. * * Revision 1.16 1995/12/23 03:44:59 robertj * Fixed unix portability issues. * * Revision 1.15 1995/12/10 11:32:11 robertj * Numerous fixes for sockets. * * Revision 1.14 1995/10/14 14:57:26 robertj * Added internet address to string conversion functionality. * * Revision 1.13 1995/07/02 01:18:19 robertj * Added static functions to get the current host name/address. * * Revision 1.12 1995/06/17 00:41:40 robertj * More logical design of port numbers and service names. * * Revision 1.11 1995/03/18 06:26:44 robertj * Changed IP address variable for GNU compatibility. * * Revision 1.10 1995/03/14 12:41:38 robertj * Updated documentation to use HTML codes. * * Revision 1.9 1995/03/12 04:38:41 robertj * Added more functionality. * * Revision 1.8 1995/01/02 12:28:24 robertj * Documentation. * Added more socket functions. * * Revision 1.7 1995/01/01 01:07:33 robertj * More implementation. * * Revision 1.6 1994/12/15 12:47:14 robertj * Documentation. * * Revision 1.5 1994/08/23 11:32:52 robertj * Oops * * Revision 1.4 1994/08/22 00:46:48 robertj * Added pragma fro GNU C++ compiler. * * Revision 1.3 1994/08/21 23:43:02 robertj * Spelt Berkeley correctly. * * Revision 1.2 1994/07/25 03:36:03 robertj * Added sockets to common, normalising to same comment standard. * */#define _PIPSOCKET#ifdef __GNUC__#pragma interface#endif#ifndef _PSOCKET#include <ptlib/socket.h>#endif/** This class describes a type of socket that will communicate using the Internet Protocol. */class PIPSocket : public PSocket{ PCLASSINFO(PIPSocket, PSocket); protected: /* Create a new Internet Protocol socket based on the port number specified. */ PIPSocket(); public: /** A class describing an IP address */ class Address : public in_addr { public: /**@name Address constructors */ //@{ /// Create an IP address with the default address Address(); /// Create an IP address with the default address Address(const PString & dotNotation); /// Create an IP address from four byte values Address(BYTE b1, BYTE b2, BYTE b3, BYTE b4); /// Create an IP address from a four byte value in network byte order Address(DWORD dw); /// Create an IP address from an in_addr structure Address(const in_addr & addr); /// Copy an address from another Address Address(const Address & addr);#ifdef __NUCLEUS_NET__ Address(const struct id_struct & addr); Address & operator=(const struct id_struct & addr);#endif /// Copy an address from another Address Address & operator=(const in_addr & addr); /// Copy an address from another Address Address & operator=(const Address & addr); /// Copy an address from a string Address & operator=(const PString & dotNotation); /// Copy an address from a four byte value in network order Address & operator=(DWORD dw); //@} /// Format an address as a string PString AsString() const; /// Format an address as a string operator PString() const; /// Return address in network order operator DWORD() const; /// Return first byte of IP address BYTE Byte1() const; /// Return second byte of IP address BYTE Byte2() const; /// Return third byte of IP address BYTE Byte3() const; /// Return fourth byte of IP address BYTE Byte4() const; /// return specified byte of IP address BYTE operator[](PINDEX idx) const; /// output address as a string to the specified string friend ostream & operator<<(ostream & s, const Address & a); /// output address as a string to the specified string friend istream & operator>>(istream & s, Address & a); }; // Overrides from class PChannel /** Get the platform and I/O channel type name of the channel. For an IP socket this returns the host name of the peer the socket is connected to, followed by the socket number it is connected to. @return the name of the channel. */ virtual PString GetName() const; // Overrides from class PSocket. /** Connect a socket to a remote host on the specified port number. This is typically used by the client or initiator of a communications channel. This connects to a "listening" socket at the other end of the communications channel.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -