00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _PIPXSOCKET
00035 #define _PIPXSOCKET
00036
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040
00041 #include <ptlib/socket.h>
00042
00043
00047 class PIPXSocket : public PSocket
00048 {
00049 PCLASSINFO(PIPXSocket, PSocket);
00050
00051 public:
00054 PIPXSocket(
00055 WORD port = 0
00056 );
00057
00058
00059 public:
00062 class Address {
00063 public:
00064 union {
00065 struct {
00066 BYTE b1,b2,b3,b4;
00067 } b;
00068 struct {
00069 WORD w1,s_w2;
00070 } w;
00071 DWORD dw;
00072 } network;
00073 BYTE node[6];
00074
00076 Address();
00078 Address(const Address & addr );
00080 Address(const PString & str );
00082 Address(
00083 DWORD netNum,
00084 const char * nodeNum
00085 );
00087 Address & operator=(const Address & addr );
00089 operator PString() const;
00094 PBoolean IsValid() const;
00096 friend ostream & operator<<(
00097 ostream & strm,
00098 Address & addr
00099 ) { return strm << (PString)addr; }
00100 };
00101
00112 virtual PString GetName() const;
00114
00115
00130 virtual PBoolean Connect(
00131 const PString & address
00132 );
00145 virtual PBoolean Connect(
00146 const Address & address
00147 );
00148
00164 virtual PBoolean Listen(
00165 unsigned queueSize = 5,
00166 WORD port = 0,
00167 Reusability reuse = AddressIsExclusive
00168 );
00170
00178 static PString GetHostName(
00179 const Address & addr
00180 );
00181
00187 static PBoolean GetHostAddress(
00188 Address & addr
00189 );
00190
00196 static PBoolean GetHostAddress(
00197 const PString & hostname,
00201 Address & addr
00202 );
00203
00209 PBoolean GetLocalAddress(
00210 Address & addr
00211 );
00212
00218 PBoolean GetLocalAddress(
00219 Address & addr,
00220 WORD & port
00221 );
00222
00229 PBoolean GetPeerAddress(
00230 Address & addr
00231 );
00232
00239 PBoolean GetPeerAddress(
00240 Address & addr,
00241 WORD & port
00242 );
00244
00252 PBoolean SetPacketType(
00253 int type
00254 );
00255
00261 int GetPacketType();
00262
00263
00269 virtual PBoolean ReadFrom(
00270 void * buf,
00271 PINDEX len,
00272 Address & addr,
00273 WORD & port
00274 );
00275
00281 virtual PBoolean WriteTo(
00282 const void * buf,
00283 PINDEX len,
00284 const Address & addr,
00285 WORD port
00286 );
00288
00289
00290 protected:
00291 virtual PBoolean OpenSocket();
00292 virtual const char * GetProtocolName() const;
00293
00294
00295
00296 #ifdef _WIN32
00297 #include "msos/ptlib/ipxsock.h"
00298 #else
00299 #include "unix/ptlib/ipxsock.h"
00300 #endif
00301 };
00302
00303 #endif
00304
00305