4 * IPX protocol socket I/O channel class.
6 * Portable Windows Library
8 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
27 * Contributor(s): ______________________________________.
30 * Revision 1.12 2005/11/25 03:43:47 csoutheren
31 * Fixed function argument comments to be compatible with Doxygen
33 * Revision 1.11 2003/09/17 05:41:58 csoutheren
34 * Removed recursive includes
36 * Revision 1.10 2003/09/17 01:18:02 csoutheren
37 * Removed recursive include file system and removed all references
38 * to deprecated coooperative threading support
40 * Revision 1.9 2002/09/16 01:08:59 robertj
41 * Added #define so can select if #pragma interface/implementation is used on
42 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
44 * Revision 1.8 2001/05/22 12:49:32 robertj
45 * Did some seriously wierd rewrite of platform headers to eliminate the
46 * stupid GNU compiler warning about braces not matching.
48 * Revision 1.7 1999/03/09 02:59:50 robertj
49 * Changed comments to doc++ compatible documentation.
51 * Revision 1.6 1999/02/16 08:12:00 robertj
52 * MSVC 6.0 compatibility changes.
54 * Revision 1.5 1998/11/30 02:50:58 robertj
55 * New directory structure
57 * Revision 1.4 1998/09/23 06:20:47 robertj
58 * Added open source copyright license.
60 * Revision 1.3 1996/10/08 13:21:04 robertj
61 * More IPX implementation.
63 * Revision 1.1 1996/09/14 13:00:56 robertj
75 #include <ptlib/socket.h>
78 /**This class describes a type of socket that will communicate using the
81 class PIPXSocket
: public PSocket
83 PCLASSINFO(PIPXSocket
, PSocket
);
86 /**Create a new IPX datagram socket.
89 WORD port
= 0 ///< Port number to use for the connection.
94 /** IPX protocol address specification.
109 /** Create new, invalid, address. */
111 /** Create copy of existing address */
112 Address(const Address
& addr
/** Address to copy */);
113 /** Create address from string representation. */
114 Address(const PString
& str
/** String representation of address */);
115 /** Create address from node and net numbers. */
117 DWORD netNum
, ///< IPX network number.
118 const char * nodeNum
///< IPX node number (MAC address)
120 /** Create copy of existing address */
121 Address
& operator=(const Address
& addr
/** Address to copy */);
122 /** Get string representation of IPX address */
123 operator PString() const;
124 /** Determine if address is valid. Note that this does not mean that
126 @return TRUE is address is valid.
128 BOOL
IsValid() const;
129 /** Output string representation of IPX address to stream. */
130 friend ostream
& operator<<(
131 ostream
& strm
, ///< Stream to output to
132 Address
& addr
///< Address to output
133 ) { return strm
<< (PString
)addr
; }
136 /**@name Overrides from class PChannel */
138 /**Get the platform and I/O channel type name of the channel. For an
139 IPX/SPX socket this returns the network number, node number of the
140 peer the socket is connected to, followed by the socket number it
144 the name of the channel.
146 virtual PString
GetName() const;
150 /**@name Overrides from class PSocket */
152 /**Connect a socket to a remote host on the port number of the socket.
154 typically used by the client or initiator of a communications channel.
155 This connects to a "listening" socket at the other end of the
156 communications channel.
158 The port number as defined by the object instance construction or the
159 #PIPSocket::SetPort()# function.
162 TRUE if the channel was successfully connected to the remote host.
164 virtual BOOL
Connect(
165 const PString
& address
///< Address of remote machine to connect to.
167 /**Connect a socket to a remote host on the port number of the socket.
169 typically used by the client or initiator of a communications channel.
170 This connects to a "listening" socket at the other end of the
171 communications channel.
173 The port number as defined by the object instance construction or the
174 #PIPSocket::SetPort()# function.
177 TRUE if the channel was successfully connected to the remote host.
179 virtual BOOL
Connect(
180 const Address
& address
///< Address of remote machine to connect to.
183 /**Listen on a socket for a remote host on the specified port number. This
184 may be used for server based applications. A "connecting" socket begins
185 a connection by initiating a connection to this socket. An active socket
186 of this type is then used to generate other "accepting" sockets which
187 establish a two way communications channel with the "connecting" socket.
189 If the #port# parameter is zero then the port number as
190 defined by the object instance construction or the
191 #PIPSocket::SetPort()# function.
193 For the UDP protocol, the #queueSize# parameter is ignored.
196 TRUE if the channel was successfully opened.
199 unsigned queueSize
= 5, ///< Number of pending accepts that may be queued.
200 WORD port
= 0, ///< Port number to use for the connection.
201 Reusability reuse
= AddressIsExclusive
///< Can/Cant listen more than once.
205 /**@name Address and name space look up functions */
207 /**Get the host name for the host specified server.
210 Name of the host or IPX number of host.
212 static PString
GetHostName(
213 const Address
& addr
///< Hosts IP address to get name for
216 /**Get the IPX address for the specified host.
219 TRUE if the IPX number was returned.
221 static BOOL
GetHostAddress(
222 Address
& addr
///< Variable to receive this hosts IP address
225 /**Get the IPX address for the specified host.
228 TRUE if the IPX number was returned.
230 static BOOL
GetHostAddress(
231 const PString
& hostname
,
232 /** Name of host to get address for. This may be either a server name or
233 an IPX number in "colon" format.
235 Address
& addr
///< Variable to receive hosts IPX address
238 /**Get the IPX/SPX address for the local host.
241 TRUE if the IPX number was returned.
243 BOOL
GetLocalAddress(
244 Address
& addr
///< Variable to receive hosts IPX address
247 /**Get the IPX/SPX address for the local host.
250 TRUE if the IPX number was returned.
252 BOOL
GetLocalAddress(
253 Address
& addr
, ///< Variable to receive peer hosts IPX address
254 WORD
& port
///< Variable to receive peer hosts port number
257 /**Get the IPX/SPX address for the peer host the socket is
261 TRUE if the IPX number was returned.
264 Address
& addr
///< Variable to receive hosts IPX address
267 /**Get the IPX/SPX address for the peer host the socket is
271 TRUE if the IPX number was returned.
274 Address
& addr
, ///< Variable to receive peer hosts IPX address
275 WORD
& port
///< Variable to receive peer hosts port number
279 /**@name I/O functions */
281 /**Sets the packet type for datagrams sent by this socket.
284 TRUE if the type was successfully set.
287 int type
///< IPX packet type for this socket.
290 /**Gets the packet type for datagrams sent by this socket.
293 type of packets or -1 if error.
298 /**Read a datagram from a remote computer.
301 TRUE if all the bytes were sucessfully written.
303 virtual BOOL
ReadFrom(
304 void * buf
, ///< Data to be written as URGENT TCP data.
305 PINDEX len
, ///< Number of bytes pointed to by #buf#.
306 Address
& addr
, ///< Address from which the datagram was received.
307 WORD
& port
///< Port from which the datagram was received.
310 /**Write a datagram to a remote computer.
313 TRUE if all the bytes were sucessfully written.
315 virtual BOOL
WriteTo(
316 const void * buf
, ///< Data to be written as URGENT TCP data.
317 PINDEX len
, ///< Number of bytes pointed to by #buf#.
318 const Address
& addr
, ///< Address to which the datagram is sent.
319 WORD port
///< Port to which the datagram is sent.
325 virtual BOOL
OpenSocket();
326 virtual const char * GetProtocolName() const;
329 // Include platform dependent part of class
331 #include "msos/ptlib/ipxsock.h"
333 #include "unix/ptlib/ipxsock.h"
339 // End Of File ///////////////////////////////////////////////////////////////