Fixed DevStudio 2003 build with memory check code.
[pwlib.git] / include / ptlib / ipxsock.h
blobf065b947dcdd57d662af55e0b5ad05ca97796603
1 /*
2 * ipxsock.h
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
18 * under the License.
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): ______________________________________.
29 * $Log$
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
64 * Initial revision
68 #ifndef _PIPXSOCKET
69 #define _PIPXSOCKET
71 #ifdef P_USE_PRAGMA
72 #pragma interface
73 #endif
75 #include <ptlib/socket.h>
78 /**This class describes a type of socket that will communicate using the
79 IPX/SPX protocols.
81 class PIPXSocket : public PSocket
83 PCLASSINFO(PIPXSocket, PSocket);
85 public:
86 /**Create a new IPX datagram socket.
88 PIPXSocket(
89 WORD port = 0 ///< Port number to use for the connection.
93 public:
94 /** IPX protocol address specification.
96 class Address {
97 public:
98 union {
99 struct {
100 BYTE b1,b2,b3,b4;
101 } b;
102 struct {
103 WORD w1,s_w2;
104 } w;
105 DWORD dw;
106 } network;
107 BYTE node[6];
109 /** Create new, invalid, address. */
110 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. */
116 Address(
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
125 the host is online.
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 */
137 //@{
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
141 is connected to.
143 @return
144 the name of the channel.
146 virtual PString GetName() const;
147 //@}
150 /**@name Overrides from class PSocket */
151 //@{
152 /**Connect a socket to a remote host on the port number of the socket.
153 This is
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.
161 @return
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.
168 This is
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.
176 @return
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.
195 @return
196 TRUE if the channel was successfully opened.
198 virtual BOOL Listen(
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.
203 //@}
205 /**@name Address and name space look up functions */
206 //@{
207 /**Get the host name for the host specified server.
209 @return
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.
218 @return
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.
227 @return
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.
240 @return
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.
249 @return
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
258 connected to.
260 @return
261 TRUE if the IPX number was returned.
263 BOOL GetPeerAddress(
264 Address & addr ///< Variable to receive hosts IPX address
267 /**Get the IPX/SPX address for the peer host the socket is
268 connected to.
270 @return
271 TRUE if the IPX number was returned.
273 BOOL GetPeerAddress(
274 Address & addr, ///< Variable to receive peer hosts IPX address
275 WORD & port ///< Variable to receive peer hosts port number
277 //@}
279 /**@name I/O functions */
280 //@{
281 /**Sets the packet type for datagrams sent by this socket.
283 @return
284 TRUE if the type was successfully set.
286 BOOL SetPacketType(
287 int type ///< IPX packet type for this socket.
290 /**Gets the packet type for datagrams sent by this socket.
292 @return
293 type of packets or -1 if error.
295 int GetPacketType();
298 /**Read a datagram from a remote computer.
300 @return
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.
312 @return
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.
321 //@}
324 protected:
325 virtual BOOL OpenSocket();
326 virtual const char * GetProtocolName() const;
329 // Include platform dependent part of class
330 #ifdef _WIN32
331 #include "msos/ptlib/ipxsock.h"
332 #else
333 #include "unix/ptlib/ipxsock.h"
334 #endif
337 #endif
339 // End Of File ///////////////////////////////////////////////////////////////