In what follows,
ty
denotes the type of the socket connection and is of type
sockbuf::type
proto
denotes the protocol and is of type int
si, ins
are sockbuf
objects and are in inet domain
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*
sd
is an integer which is a socket descriptor
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
sockinetbuf ins(ty, proto)
sockinetbuf
object ins
whose socket
communication type is ty
and protocol is proto
.
proto
defaults to 0.
sockinetbuf ins(sd)
sockinetbuf
object ins
using the open socket sd
.
ins = si
sockbuf::operator=
.
See sockbuf Class, for more details.
ins.open(ty, proto)
sockinetbuf
whose type and protocol are
ty
and proto
respectively and assign it to ins
.
sockinetaddr sina = ins.localaddr()
sockinetbuf
object
ins
. The call will make sense only after a call to either
sockbuf::bind
or sockbuf::connect
.
sockinetaddr sina = ins.peeraddr()
sockinetbuf
object
ins
. The call will make sense only after a call to
sockbuf::connect
.
const char* hn = ins.localhost()
sockinetbuf
object
ins
. The call will make sense only after a call to either
sockbuf::bind
or sockbuf::connect
.
const char* hn = ins.peerhost()
sockinetbuf
object
ins
. The call will make sense only after a call to
sockbuf::connect
.
int pn = ins.localport()
sockinetbuf
object
ins
in host byte order. The call will make sense only after a
call to either sockbuf::bind
or sockbuf::connect
.
int pn = ins.peerport()
sockinetbuf
object
ins
in local host byte order. The call will make sense only after a
call to sockbuf::connect
.
ins.bind ()
ins
to the default address INADDR_ANY and the default
port. It returns 0 on success and returns the errno on failure.
ins.bind (adr, portno)
ins
to the address adr
and the port portno
.
It returns 0 on success and returns the errno on failure.
ins.bind (adr, serv, proto)
ins
to the address, adr
and the port corresponding to
the service serv
and the protocol proto
>.
It returns 0 on success and returns the errno on failure.
ins.bind (thostname, portno)
ins
to the address corresponding to the hostname
thostname
and the port portno
.
It returns 0 on success and returns the errno on failure.
ins.bind (thostname, serv, proto)
ins
to the address corresponding to the hostname
thostname
and the port corresponding to the service serv
and the protocol proto
>. It returns 0 on success and
returns the errno on failure.
ins.connect (adr, portno)
ins
to the address adr
and the port portno
.
It returns 0 on success and returns the errno on failure.
ins.connect (adr, serv, proto)
ins
to the address, adr
and the port corresponding to
the service serv
and the protocol proto
>.
It returns 0 on success and returns the errno on failure.
ins.connect (thostname, portno)
ins
to the address corresponding to the hostname
thostname
and the port portno
.
It returns 0 on success and returns the errno on failure.
ins.connect (thostname, serv, proto)
ins
to the address corresponding to the hostname
thostname
and the port corresponding to the service serv
and the protocol proto
>.
It returns 0 on success and returns the errno on failure.