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.11 2003/09/17 05:41:58 csoutheren
31 * Removed recursive includes
33 * Revision 1.10 2003/09/17 01:18:02 csoutheren
34 * Removed recursive include file system and removed all references
35 * to deprecated coooperative threading support
37 * Revision 1.9 2002/09/16 01:08:59 robertj
38 * Added #define so can select if #pragma interface/implementation is used on
39 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
41 * Revision 1.8 2001/05/22 12:49:32 robertj
42 * Did some seriously wierd rewrite of platform headers to eliminate the
43 * stupid GNU compiler warning about braces not matching.
45 * Revision 1.7 1999/03/09 02:59:50 robertj
46 * Changed comments to doc++ compatible documentation.
48 * Revision 1.6 1999/02/16 08:12:00 robertj
49 * MSVC 6.0 compatibility changes.
51 * Revision 1.5 1998/11/30 02:50:58 robertj
52 * New directory structure
54 * Revision 1.4 1998/09/23 06:20:47 robertj
55 * Added open source copyright license.
57 * Revision 1.3 1996/10/08 13:21:04 robertj
58 * More IPX implementation.
60 * Revision 1.1 1996/09/14 13:00:56 robertj
72 #include <ptlib/socket.h>
75 /**This class describes a type of socket that will communicate using the
78 class PIPXSocket
: public PSocket
80 PCLASSINFO(PIPXSocket
, PSocket
);
83 /**Create a new IPX datagram socket.
86 WORD port
= 0 /// Port number to use for the connection.
91 /** IPX protocol address specification.
106 /** Create new, invalid, address. */
108 /** Create copy of existing address */
109 Address(const Address
& addr
/** Address to copy */);
110 /** Create address from string representation. */
111 Address(const PString
& str
/** String representation of address */);
112 /** Create address from node and net numbers. */
114 DWORD netNum
, /// IPX network number.
115 const char * nodeNum
/// IPX node number (MAC address)
117 /** Create copy of existing address */
118 Address
& operator=(const Address
& addr
/** Address to copy */);
119 /** Get string representation of IPX address */
120 operator PString() const;
121 /** Determine if address is valid. Note that this does not mean that
123 @return TRUE is address is valid.
125 BOOL
IsValid() const;
126 /** Output string representation of IPX address to stream. */
127 friend ostream
& operator<<(
128 ostream
& strm
, /// Stream to output to
129 Address
& addr
/// Address to output
130 ) { return strm
<< (PString
)addr
; }
133 /**@name Overrides from class PChannel */
135 /**Get the platform and I/O channel type name of the channel. For an
136 IPX/SPX socket this returns the network number, node number of the
137 peer the socket is connected to, followed by the socket number it
141 the name of the channel.
143 virtual PString
GetName() const;
147 /**@name Overrides from class PSocket */
149 /**Connect a socket to a remote host on the port number of the socket.
151 typically used by the client or initiator of a communications channel.
152 This connects to a "listening" socket at the other end of the
153 communications channel.
155 The port number as defined by the object instance construction or the
156 #PIPSocket::SetPort()# function.
159 TRUE if the channel was successfully connected to the remote host.
161 virtual BOOL
Connect(
162 const PString
& address
/// Address of remote machine to connect to.
164 /**Connect a socket to a remote host on the port number of the socket.
166 typically used by the client or initiator of a communications channel.
167 This connects to a "listening" socket at the other end of the
168 communications channel.
170 The port number as defined by the object instance construction or the
171 #PIPSocket::SetPort()# function.
174 TRUE if the channel was successfully connected to the remote host.
176 virtual BOOL
Connect(
177 const Address
& address
/// Address of remote machine to connect to.
180 /**Listen on a socket for a remote host on the specified port number. This
181 may be used for server based applications. A "connecting" socket begins
182 a connection by initiating a connection to this socket. An active socket
183 of this type is then used to generate other "accepting" sockets which
184 establish a two way communications channel with the "connecting" socket.
186 If the #port# parameter is zero then the port number as
187 defined by the object instance construction or the
188 #PIPSocket::SetPort()# function.
190 For the UDP protocol, the #queueSize# parameter is ignored.
193 TRUE if the channel was successfully opened.
196 unsigned queueSize
= 5, /// Number of pending accepts that may be queued.
197 WORD port
= 0, /// Port number to use for the connection.
198 Reusability reuse
= AddressIsExclusive
/// Can/Cant listen more than once.
202 /**@name Address and name space look up functions */
204 /**Get the host name for the host specified server.
207 Name of the host or IPX number of host.
209 static PString
GetHostName(
210 const Address
& addr
/// Hosts IP address to get name for
213 /**Get the IPX address for the specified host.
216 TRUE if the IPX number was returned.
218 static BOOL
GetHostAddress(
219 Address
& addr
/// Variable to receive this hosts IP address
222 /**Get the IPX address for the specified host.
225 TRUE if the IPX number was returned.
227 static BOOL
GetHostAddress(
228 const PString
& hostname
,
229 /** Name of host to get address for. This may be either a server name or
230 an IPX number in "colon" format.
232 Address
& addr
/// Variable to receive hosts IPX address
235 /**Get the IPX/SPX address for the local host.
238 TRUE if the IPX number was returned.
240 BOOL
GetLocalAddress(
241 Address
& addr
/// Variable to receive hosts IPX address
244 /**Get the IPX/SPX address for the local host.
247 TRUE if the IPX number was returned.
249 BOOL
GetLocalAddress(
250 Address
& addr
, /// Variable to receive peer hosts IPX address
251 WORD
& port
/// Variable to receive peer hosts port number
254 /**Get the IPX/SPX address for the peer host the socket is
258 TRUE if the IPX number was returned.
261 Address
& addr
/// Variable to receive hosts IPX address
264 /**Get the IPX/SPX address for the peer host the socket is
268 TRUE if the IPX number was returned.
271 Address
& addr
, /// Variable to receive peer hosts IPX address
272 WORD
& port
/// Variable to receive peer hosts port number
276 /**@name I/O functions */
278 /**Sets the packet type for datagrams sent by this socket.
281 TRUE if the type was successfully set.
284 int type
/// IPX packet type for this socket.
287 /**Gets the packet type for datagrams sent by this socket.
290 type of packets or -1 if error.
295 /**Read a datagram from a remote computer.
298 TRUE if all the bytes were sucessfully written.
300 virtual BOOL
ReadFrom(
301 void * buf
, /// Data to be written as URGENT TCP data.
302 PINDEX len
, /// Number of bytes pointed to by #buf#.
303 Address
& addr
, /// Address from which the datagram was received.
304 WORD
& port
/// Port from which the datagram was received.
307 /**Write a datagram to a remote computer.
310 TRUE if all the bytes were sucessfully written.
312 virtual BOOL
WriteTo(
313 const void * buf
, /// Data to be written as URGENT TCP data.
314 PINDEX len
, /// Number of bytes pointed to by #buf#.
315 const Address
& addr
, /// Address to which the datagram is sent.
316 WORD port
/// Port to which the datagram is sent.
322 virtual BOOL
OpenSocket();
323 virtual const char * GetProtocolName() const;
326 // Include platform dependent part of class
328 #include "msos/ptlib/ipxsock.h"
330 #include "unix/ptlib/ipxsock.h"
336 // End Of File ///////////////////////////////////////////////////////////////