<
html
>
<
head
>
<
title
>pinet.h</
title
>
<
style
type
=
"text/css"
>
/*
Webcpp v0.8.1 compatible StyleSheet
Theme: ide-msvcpp
*/
body
{
background-color: #ffffff
}
.webcpp a:link {color:#000000}
.webcpp a:visited {color:#008000}
.webcpp a:active {color:#0000ff}
.webcpp a:hover {color:#0000ff}
.webcpp pre
{
color: #000000
}
.webcpp font
{
font-size:100%
}
.webcpp .symbols
{
color: #000000
}
.webcpp .preproc
{
color: #0000ff
}
.webcpp .integer
{
color: #000000
}
.webcpp .floatpt
{
color: #000000
}
.webcpp .dblquot
{
color: #000000
}
.webcpp .sinquot
{
color: #000000
}
.webcpp .keyword
{
color: #0000ff;
}
.webcpp .keytype
{
color: #0000ff;
}
.webcpp .comment
{
color: #008000;
}
</
style
>
</
head
>
<
body
bgcolor
=
"#FFFFFF"
leftmargin
=
"40"
marginwidth
=
"40"
> <
p
><
a
href
=
"../htsrc.html"
>Index</
a
><
hr
noshade></
p
>
<
div
class
=
"webcpp"
>
<
pre
>
<
font
CLASS
=
preproc
>#ifndef</
font
> __PINET_H__
<
font
CLASS
=
preproc
>#define</
font
> __PINET_H__
<
font
CLASS
=
preproc
>#ifndef</
font
> __PPORT_H__
<
font
CLASS
=
preproc
>#include</
font
> <
font
CLASS
=
dblquot
>"pport.h"</
font
>
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
preproc
>#ifndef</
font
> __PTYPES_H__
<
font
CLASS
=
preproc
>#include</
font
> <
font
CLASS
=
dblquot
>"ptypes.h"</
font
>
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
preproc
>#ifndef</
font
> __PSTREAMS_H__
<
font
CLASS
=
preproc
>#include</
font
> <
font
CLASS
=
dblquot
>"pstreams.h"</
font
>
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
preproc
>#ifdef</
font
> WIN32
<
font
CLASS
=
preproc
>#</
font
> include <
winsock2.h
>
<
font
CLASS
=
preproc
>#else</
font
>
<
font
CLASS
=
preproc
>#</
font
> include <
netdb.h
> <
font
CLASS
=
comment
>// for socklen_t </
font
>
<
font
CLASS
=
preproc
>#</
font
> include <
sys
/types.h>
<
font
CLASS
=
preproc
>#</
font
> include <
sys
/socket.h>
<
font
CLASS
=
preproc
>#endif</
font
>
PTYPES_BEGIN
<
font
CLASS
=
preproc
>#ifdef</
font
> _MSC_VER
<
font
CLASS
=
preproc
>#pragma</
font
> pack(push, <
font
CLASS
=
integer
>4</
font
>)
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// BSD-compatible socket error codes for Win32</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
preproc
>#if</
font
> defined(WSAENOTSOCK) && !defined(ENOTSOCK)
<
font
CLASS
=
preproc
>#define</
font
> EWOULDBLOCK WSAEWOULDBLOCK
<
font
CLASS
=
preproc
>#define</
font
> EINPROGRESS WSAEINPROGRESS
<
font
CLASS
=
preproc
>#define</
font
> EALREADY WSAEALREADY
<
font
CLASS
=
preproc
>#define</
font
> ENOTSOCK WSAENOTSOCK
<
font
CLASS
=
preproc
>#define</
font
> EDESTADDRREQ WSAEDESTADDRREQ
<
font
CLASS
=
preproc
>#define</
font
> EMSGSIZE WSAEMSGSIZE
<
font
CLASS
=
preproc
>#define</
font
> EPROTOTYPE WSAEPROTOTYPE
<
font
CLASS
=
preproc
>#define</
font
> ENOPROTOOPT WSAENOPROTOOPT
<
font
CLASS
=
preproc
>#define</
font
> EPROTONOSUPPORT WSAEPROTONOSUPPORT
<
font
CLASS
=
preproc
>#define</
font
> ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
<
font
CLASS
=
preproc
>#define</
font
> EOPNOTSUPP WSAEOPNOTSUPP
<
font
CLASS
=
preproc
>#define</
font
> EPFNOSUPPORT WSAEPFNOSUPPORT
<
font
CLASS
=
preproc
>#define</
font
> EAFNOSUPPORT WSAEAFNOSUPPORT
<
font
CLASS
=
preproc
>#define</
font
> EADDRINUSE WSAEADDRINUSE
<
font
CLASS
=
preproc
>#define</
font
> EADDRNOTAVAIL WSAEADDRNOTAVAIL
<
font
CLASS
=
preproc
>#define</
font
> ENETDOWN WSAENETDOWN
<
font
CLASS
=
preproc
>#define</
font
> ENETUNREACH WSAENETUNREACH
<
font
CLASS
=
preproc
>#define</
font
> ENETRESET WSAENETRESET
<
font
CLASS
=
preproc
>#define</
font
> ECONNABORTED WSAECONNABORTED
<
font
CLASS
=
preproc
>#define</
font
> ECONNRESET WSAECONNRESET
<
font
CLASS
=
preproc
>#define</
font
> ENOBUFS WSAENOBUFS
<
font
CLASS
=
preproc
>#define</
font
> EISCONN WSAEISCONN
<
font
CLASS
=
preproc
>#define</
font
> ENOTCONN WSAENOTCONN
<
font
CLASS
=
preproc
>#define</
font
> ESHUTDOWN WSAESHUTDOWN
<
font
CLASS
=
preproc
>#define</
font
> ETOOMANYREFS WSAETOOMANYREFS
<
font
CLASS
=
preproc
>#define</
font
> ETIMEDOUT WSAETIMEDOUT
<
font
CLASS
=
preproc
>#define</
font
> ECONNREFUSED WSAECONNREFUSED
<
font
CLASS
=
preproc
>#define</
font
> ELOOP WSAELOOP
<
font
CLASS
=
comment
>// #define ENAMETOOLONG WSAENAMETOOLONG</
font
>
<
font
CLASS
=
preproc
>#define</
font
> EHOSTDOWN WSAEHOSTDOWN
<
font
CLASS
=
preproc
>#define</
font
> EHOSTUNREACH WSAEHOSTUNREACH
<
font
CLASS
=
comment
>// #define ENOTEMPTY WSAENOTEMPTY</
font
>
<
font
CLASS
=
preproc
>#define</
font
> EPROCLIM WSAEPROCLIM
<
font
CLASS
=
preproc
>#define</
font
> EUSERS WSAEUSERS
<
font
CLASS
=
preproc
>#define</
font
> EDQUOT WSAEDQUOT
<
font
CLASS
=
preproc
>#define</
font
> ESTALE WSAESTALE
<
font
CLASS
=
preproc
>#define</
font
> EREMOTE WSAEREMOTE
<
font
CLASS
=
comment
>// NOTE: these are not errno constants in UNIX!</
font
>
<
font
CLASS
=
preproc
>#define</
font
> HOST_NOT_FOUND WSAHOST_NOT_FOUND
<
font
CLASS
=
preproc
>#define</
font
> TRY_AGAIN WSATRY_AGAIN
<
font
CLASS
=
preproc
>#define</
font
> NO_RECOVERY WSANO_RECOVERY
<
font
CLASS
=
preproc
>#define</
font
> NO_DATA WSANO_DATA
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
comment
>// shutdown() constants</
font
>
<
font
CLASS
=
preproc
>#if</
font
> defined(SD_RECEIVE) && !defined(SHUT_RD)
<
font
CLASS
=
preproc
>#</
font
> define SHUT_RD SD_RECEIVE
<
font
CLASS
=
preproc
>#</
font
> define SHUT_WR SD_SEND
<
font
CLASS
=
preproc
>#</
font
> define SHUT_RDWR SD_BOTH
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
comment
>// max backlog value for listen()</
font
>
<
font
CLASS
=
preproc
>#ifndef</
font
> SOMAXCONN
<
font
CLASS
=
preproc
>#</
font
> define SOMAXCONN <
font
CLASS
=
symbols
>-</
font
><
font
CLASS
=
integer
>1</
font
>
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
keyword
>typedef</
font
> <
font
CLASS
=
keytype
>char</
font
>* sockval_t;
<
font
CLASS
=
preproc
>#ifndef</
font
> WIN32
<
font
CLASS
=
preproc
>#</
font
> define closesocket close
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
preproc
>#if</
font
> (defined(__DARWIN__) && !defined(_SOCKLEN_T)) <
font
CLASS
=
symbols
>||</
font
> defined(WIN32) <
font
CLASS
=
symbols
>||</
font
> defined(__hpux)
<
font
CLASS
=
keyword
>typedef</
font
> <
font
CLASS
=
keytype
>int</
font
> psocklen;
<
font
CLASS
=
preproc
>#else</
font
>
<
font
CLASS
=
keyword
>typedef</
font
> socklen_t psocklen;
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
comment
>// -------------------------------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>// --- IP address class and DNS utilities ---------------------------- //</
font
>
<
font
CLASS
=
comment
>// -------------------------------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// IP address</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
keyword
>struct</
font
> ipaddress
{
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
<
font
CLASS
=
keyword
>union</
font
>
{
uchar data[<
font
CLASS
=
integer
>4</
font
>];
ulong ldata;
};
ipaddress() {}
ipaddress(ulong a) { ldata <
font
CLASS
=
symbols
>=</
font
> a; }
ipaddress(<
font
CLASS
=
keyword
>const</
font
> ipaddress& a) { ldata <
font
CLASS
=
symbols
>=</
font
> a.ldata; }
ipaddress(<
font
CLASS
=
keytype
>int</
font
> a, <
font
CLASS
=
keytype
>int</
font
> b, <
font
CLASS
=
keytype
>int</
font
> c, <
font
CLASS
=
keytype
>int</
font
> d);
ipaddress& <
font
CLASS
=
keyword
>operator</
font
><
font
CLASS
=
symbols
>=</
font
> (ulong a) { ldata <
font
CLASS
=
symbols
>=</
font
> a; <
font
CLASS
=
keyword
>return</
font
> *<
font
CLASS
=
keyword
>this</
font
>; }
ipaddress& <
font
CLASS
=
keyword
>operator</
font
><
font
CLASS
=
symbols
>=</
font
> (<
font
CLASS
=
keyword
>const</
font
> ipaddress& a) { ldata <
font
CLASS
=
symbols
>=</
font
> a.ldata; <
font
CLASS
=
keyword
>return</
font
> *<
font
CLASS
=
keyword
>this</
font
>; }
uchar& <
font
CLASS
=
keyword
>operator</
font
> [] (<
font
CLASS
=
keytype
>int</
font
> i) { <
font
CLASS
=
keyword
>return</
font
> data[i]; }
<
font
CLASS
=
keyword
>operator</
font
> ulong() <
font
CLASS
=
keyword
>const</
font
> { <
font
CLASS
=
keyword
>return</
font
> ldata; }
};
<
font
CLASS
=
keyword
>extern</
font
> ipaddress ipnone;
<
font
CLASS
=
keyword
>extern</
font
> ipaddress ipany;
<
font
CLASS
=
keyword
>extern</
font
> ipaddress ipbcast;
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// IP peer info: host name, IP and the port name</
font
>
<
font
CLASS
=
comment
>// used internally in ipstream and ipmessage</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
keyword
>class</
font
> ippeerinfo: public noncopyable
{
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>protected</
font
>:</
font
>
ipaddress ip; <
font
CLASS
=
comment
>// target IP</
font
>
string host; <
font
CLASS
=
comment
>// target host name; either IP or hostname must be specified</
font
>
<
font
CLASS
=
keytype
>int</
font
> port; <
font
CLASS
=
comment
>// target port number</
font
>
<
font
CLASS
=
keytype
>void</
font
> notfound(); <
font
CLASS
=
comment
>// throws a (estream*) exception</
font
>
<
font
CLASS
=
keyword
>friend</
font
> <
font
CLASS
=
keytype
>bool</
font
> psockname(<
font
CLASS
=
keytype
>int</
font
>, ippeerinfo&);
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
ippeerinfo();
ippeerinfo(ipaddress iip, <
font
CLASS
=
keyword
>const</
font
> string& ihost, <
font
CLASS
=
keytype
>int</
font
> iport);
ipaddress get_ip(); <
font
CLASS
=
comment
>// resolves the host name if necessary (only once)</
font
>
string get_host(); <
font
CLASS
=
comment
>// performs reverse-lookup if necessary (only once)</
font
>
<
font
CLASS
=
keytype
>int</
font
> get_port() { <
font
CLASS
=
keyword
>return</
font
> port; }
<
font
CLASS
=
keytype
>void</
font
> clear();
string asstring(<
font
CLASS
=
keytype
>bool</
font
> showport) <
font
CLASS
=
keyword
>const</
font
>;
};
string iptostring(ipaddress ip);
ipaddress phostbyname(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* name);
string phostbyaddr(ipaddress ip);
string phostcname(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* name);
<
font
CLASS
=
comment
>// internal utilities</
font
>
<
font
CLASS
=
keytype
>int</
font
> usockerrno();
<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* usockerrmsg(<
font
CLASS
=
keytype
>int</
font
> code);
<
font
CLASS
=
keytype
>bool</
font
> psockwait(<
font
CLASS
=
keytype
>int</
font
> handle, <
font
CLASS
=
keytype
>int</
font
> timeout);
<
font
CLASS
=
keytype
>bool</
font
> psockname(<
font
CLASS
=
keytype
>int</
font
> handle, ippeerinfo&);
<
font
CLASS
=
comment
>// -------------------------------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>// --- TCP socket classes -------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>// -------------------------------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>// additional IO status codes</
font
>
<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>int</
font
> IO_RESOLVING <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
integer
>10</
font
>;
<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>int</
font
> IO_RESOLVED <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
integer
>11</
font
>;
<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>int</
font
> IO_CONNECTING <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
integer
>20</
font
>;
<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>int</
font
> IO_CONNECTED <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
integer
>21</
font
>;
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// ipstream</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
keyword
>class</
font
> ipstream: public fdxstm, <
font
CLASS
=
keyword
>public</
font
> ippeerinfo
{
<
font
CLASS
=
keyword
>friend</
font
> <
font
CLASS
=
keyword
>class</
font
> ipstmserver;
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>protected</
font
>:</
font
>
<
font
CLASS
=
keytype
>int</
font
> svsocket; <
font
CLASS
=
comment
>// server socket descriptor, used internally by ipstmserver</
font
>
<
font
CLASS
=
preproc
>#ifdef</
font
> WIN32
// sockets are not compatible with file handles on Windows
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>int</
font
> dorawread(<
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count);
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>int</
font
> dorawwrite(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count);
<
font
CLASS
=
preproc
>#endif</
font
>
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>int</
font
> uerrno();
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* uerrmsg(<
font
CLASS
=
keytype
>int</
font
> code);
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> doopen();
<
font
CLASS
=
keyword
>virtual</
font
> large doseek(large newpos, ioseekmode mode);
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> doclose();
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> sockopt(<
font
CLASS
=
keytype
>int</
font
> socket);
<
font
CLASS
=
keytype
>void</
font
> closehandle();
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
ipstream();
ipstream(ipaddress ip, <
font
CLASS
=
keytype
>int</
font
> port);
ipstream(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* host, <
font
CLASS
=
keytype
>int</
font
> port);
ipstream(<
font
CLASS
=
keyword
>const</
font
> string& host, <
font
CLASS
=
keytype
>int</
font
> port);
<
font
CLASS
=
keyword
>virtual</
font
> ~ipstream();
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>int</
font
> classid();
<
font
CLASS
=
keyword
>virtual</
font
> string get_streamname();
<
font
CLASS
=
keytype
>bool</
font
> waitfor(<
font
CLASS
=
keytype
>int</
font
> timeout);
ipaddress get_myip();
<
font
CLASS
=
keytype
>int</
font
> get_myport();
<
font
CLASS
=
keytype
>void</
font
> set_ip(ipaddress);
<
font
CLASS
=
keytype
>void</
font
> set_host(<
font
CLASS
=
keyword
>const</
font
> string&);
<
font
CLASS
=
keytype
>void</
font
> set_host(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>*);
<
font
CLASS
=
keytype
>void</
font
> set_port(<
font
CLASS
=
keytype
>int</
font
>);
};
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// common internal interfaces for ipstmserver and ipmsgserver</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
keyword
>class</
font
> ipbindinfo: <
font
CLASS
=
keyword
>public</
font
> unknown, <
font
CLASS
=
keyword
>public</
font
> ippeerinfo
{
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
<
font
CLASS
=
keytype
>int</
font
> handle;
ipbindinfo(ipaddress iip, <
font
CLASS
=
keyword
>const</
font
> string& ihost, <
font
CLASS
=
keytype
>int</
font
> iport);
<
font
CLASS
=
keyword
>virtual</
font
> ~ipbindinfo();
};
<
font
CLASS
=
keyword
>class</
font
> ipsvbase: public unknown
{
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>protected</
font
>:</
font
>
<
font
CLASS
=
keytype
>int</
font
> socktype;
<
font
CLASS
=
keytype
>bool</
font
> active;
tobjlist<
ipbindinfo
> addrlist; <
font
CLASS
=
comment
>// list of local socket addresses to bind to</
font
>
<
font
CLASS
=
keytype
>void</
font
> error(ippeerinfo& peer, <
font
CLASS
=
keytype
>int</
font
> code, <
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* defmsg);
<
font
CLASS
=
keytype
>bool</
font
> dopoll(<
font
CLASS
=
keytype
>int</
font
>* i, <
font
CLASS
=
keytype
>int</
font
> timeout);
<
font
CLASS
=
keytype
>void</
font
> setupfds(<
font
CLASS
=
keytype
>void</
font
>* set, <
font
CLASS
=
keytype
>int</
font
> i);
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> open();
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> close();
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> dobind(ipbindinfo*) <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
integer
>0</
font
>;
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> sockopt(<
font
CLASS
=
keytype
>int</
font
> socket);
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
ipsvbase(<
font
CLASS
=
keytype
>int</
font
> isocktype);
<
font
CLASS
=
keyword
>virtual</
font
> ~ipsvbase();
<
font
CLASS
=
keytype
>int</
font
> bind(ipaddress ip, <
font
CLASS
=
keytype
>int</
font
> port);
<
font
CLASS
=
keytype
>int</
font
> bindall(<
font
CLASS
=
keytype
>int</
font
> port);
<
font
CLASS
=
keytype
>int</
font
> get_addrcount() { <
font
CLASS
=
keyword
>return</
font
> addrlist.get_count(); }
<
font
CLASS
=
keyword
>const</
font
> ipbindinfo& get_addr(<
font
CLASS
=
keytype
>int</
font
> i) { <
font
CLASS
=
keyword
>return</
font
> *addrlist[i]; }
<
font
CLASS
=
keytype
>void</
font
> clear();
};
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// ipstmserver</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
keyword
>class</
font
> ipstmserver: public ipsvbase
{
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>protected</
font
>:</
font
>
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> dobind(ipbindinfo*);
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
ipstmserver();
<
font
CLASS
=
keyword
>virtual</
font
> ~ipstmserver();
<
font
CLASS
=
keytype
>bool</
font
> poll(<
font
CLASS
=
keytype
>int</
font
> i <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
symbols
>-</
font
><
font
CLASS
=
integer
>1</
font
>, <
font
CLASS
=
keytype
>int</
font
> timeout = <
font
CLASS
=
integer
>0</
font
>);
<
font
CLASS
=
keytype
>bool</
font
> serve(ipstream& client, <
font
CLASS
=
keytype
>int</
font
> i <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
symbols
>-</
font
><
font
CLASS
=
integer
>1</
font
>, <
font
CLASS
=
keytype
>int</
font
> timeout = -<
font
CLASS
=
integer
>1</
font
>);
};
<
font
CLASS
=
comment
>// -------------------------------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>// --- UDP socket classes -------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>// -------------------------------------------------------------------- //</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// ipmessage</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
keyword
>class</
font
> ipmessage: public unknown, <
font
CLASS
=
keyword
>public</
font
> ippeerinfo
{
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>protected</
font
>:</
font
>
<
font
CLASS
=
keytype
>int</
font
> handle;
<
font
CLASS
=
keytype
>void</
font
> error(<
font
CLASS
=
keytype
>int</
font
> code, <
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* msg);
<
font
CLASS
=
keytype
>void</
font
> open();
<
font
CLASS
=
keytype
>void</
font
> close();
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> sockopt(<
font
CLASS
=
keytype
>int</
font
> socket);
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
ipmessage();
ipmessage(ipaddress ip, <
font
CLASS
=
keytype
>int</
font
> port);
ipmessage(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* host, <
font
CLASS
=
keytype
>int</
font
> port);
ipmessage(<
font
CLASS
=
keyword
>const</
font
> string& host, <
font
CLASS
=
keytype
>int</
font
> port);
<
font
CLASS
=
keyword
>virtual</
font
> ~ipmessage();
<
font
CLASS
=
keytype
>void</
font
> set_ip(ipaddress iip);
<
font
CLASS
=
keytype
>void</
font
> set_host(<
font
CLASS
=
keyword
>const</
font
> string&);
<
font
CLASS
=
keytype
>void</
font
> set_host(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>*);
<
font
CLASS
=
keytype
>void</
font
> set_port(<
font
CLASS
=
keytype
>int</
font
>);
ipaddress get_myip();
<
font
CLASS
=
keytype
>int</
font
> get_myport();
<
font
CLASS
=
keytype
>int</
font
> get_handle() { <
font
CLASS
=
keyword
>return</
font
> handle; }
<
font
CLASS
=
keytype
>bool</
font
> waitfor(<
font
CLASS
=
keytype
>int</
font
> timeout);
<
font
CLASS
=
keytype
>int</
font
> receive(<
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count, ipaddress& src);
<
font
CLASS
=
keytype
>int</
font
> receive(<
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count);
string receive(<
font
CLASS
=
keytype
>int</
font
> max, ipaddress& src);
string receive(<
font
CLASS
=
keytype
>int</
font
> max);
<
font
CLASS
=
keytype
>void</
font
> send(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count);
<
font
CLASS
=
keytype
>void</
font
> send(<
font
CLASS
=
keyword
>const</
font
> string& s) { send(s, length(s)); }
};
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
comment
>// ipmsgserver</
font
>
<
font
CLASS
=
comment
>//</
font
>
<
font
CLASS
=
keyword
>class</
font
> ipmsgserver: public ipsvbase, <
font
CLASS
=
keyword
>public</
font
> ippeerinfo
{
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>protected</
font
>:</
font
>
<
font
CLASS
=
keytype
>int</
font
> handle;
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> close();
<
font
CLASS
=
keyword
>virtual</
font
> <
font
CLASS
=
keytype
>void</
font
> dobind(ipbindinfo*);
<
font
CLASS
=
preproc
><
font
CLASS
=
keyword
>public</
font
>:</
font
>
ipmsgserver();
<
font
CLASS
=
keyword
>virtual</
font
> ~ipmsgserver();
<
font
CLASS
=
keytype
>int</
font
> get_handle() { <
font
CLASS
=
keyword
>return</
font
> handle; }
<
font
CLASS
=
keytype
>bool</
font
> poll(<
font
CLASS
=
keytype
>int</
font
> i <
font
CLASS
=
symbols
>=</
font
> <
font
CLASS
=
symbols
>-</
font
><
font
CLASS
=
integer
>1</
font
>, <
font
CLASS
=
keytype
>int</
font
> timeout = <
font
CLASS
=
integer
>0</
font
>);
<
font
CLASS
=
keytype
>int</
font
> receive(<
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count);
string receive(<
font
CLASS
=
keytype
>int</
font
> max);
<
font
CLASS
=
keytype
>void</
font
> send(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count);
<
font
CLASS
=
keytype
>void</
font
> send(<
font
CLASS
=
keyword
>const</
font
> string& s) { send(s, length(s)); }
<
font
CLASS
=
keytype
>void</
font
> sendto(<
font
CLASS
=
keyword
>const</
font
> <
font
CLASS
=
keytype
>char</
font
>* buf, <
font
CLASS
=
keytype
>int</
font
> count, ipaddress ip, <
font
CLASS
=
keytype
>int</
font
> port);
<
font
CLASS
=
keytype
>void</
font
> sendto(<
font
CLASS
=
keyword
>const</
font
> string& s, ipaddress ip, <
font
CLASS
=
keytype
>int</
font
> port)
{ sendto(s, length(s), ip, port); }
};
<
font
CLASS
=
preproc
>#ifdef</
font
> _MSC_VER
<
font
CLASS
=
preproc
>#pragma</
font
> pack(pop)
<
font
CLASS
=
preproc
>#endif</
font
>
PTYPES_END
<
font
CLASS
=
preproc
>#endif</
font
> <
font
CLASS
=
comment
>// __PINET_H__ </
font
>
</
pre
>
</
div
>
<
hr
noshade></
body
>
</
html
>