Class sockinetaddr
is derived from sockAddr
declared in
<sockstream.h>
and from sockaddr_in
declared in
<netinet/in.h>
. Always use a sockinetaddr
object for an
address with inet domain of sockets. See Connection Establishment.
In what follows,
adr
denotes an inet address in host byte order and is of
type unsigned long
serv
denotes a service like "nntp" and is of type char*
proto
denotes a protocol like "tcp" and is of type char*
thostname
is of type char* and denotes the name of a host like
"kelvin.acc.virginia.edu"
or "128.143.24.31"
.
portno
denotes a port in host byte order and is of type int
sockinetaddr sina
sockinetaddr
object sina
with default address
INADDR_ANY and default port number 0.
sockinetaddr sina(adr, portno)
sockinetaddr
object sina
setting inet address
to adr
and the port number to portno
. portno
defaults to 0.
sockinetaddr sina(adr, serv, proto)
sockinetaddr
object sina
setting inet address
to adr
and the port number corresponding to the service
serv
and the protocol proto
. The protocol defaults to "tcp".
sockinetaddr sina(thostname, portno)
sockinetaddr
object sina
setting inet address
to the address of thostname
and the port number to portno
.
portno
defaults to 0.
sockinetaddr sina(thostname, serv, proto)
sockinetaddr
object sina
setting inet address
to the address of thostname
and the port number corresponding to
the service serv
and the protocol proto
. The protocol
defaults to "tcp".
void* a = sina
sockaddr_in
part of
sockinetaddr
object sina
as void*.
int sz = sina.size()
sockaddr_in
part of sockinetaddr
object
sina
.
int af = sina.family()
sockinetbuf::af_inet
if all is well.
int pn = sina.getport()
sockinetaddr
object sina
in
host byte order.
const char* hn = getthostname()
sockinetaddr
object sina
.