Next: TCPIPV6NetworkStreamReader, Previous: TCPIPNetworkStreamWriter, Up: Classes [Index]
TCPIPV6UNIXNetworkStream
ClassThe TCPIPV6NetworkStream
class manages TCPIP version 6 stream
objects. The class is a superclass of the
TCPIPV6NetworkStreamReader
and
TCPIPV6NetworkStreamWriter
classes, and the methods and
instance variables that are defined by this class are common to both
client and server programs.
Here is an example of simple IPv6 reader program.
int main () { SystemErrnoException new ex; TCPIPV6NetworkStreamReader new server, connection; String new data; server openOn; if (ex pending) { ex handle; } connection = server acceptSock; if (ex pending) { ex handle; } data = server readText connection; printf ("%s\n", data); server closeSock; }
And here is a simple program that writes a message to a TCPIP v6 connection.
static char *msg = "First connect.\n"; #include <ctalk/ctalkdefs.h> int main (int argc, char **argv) { SystemErrnoException new ex; TCPIPV6NetworkStreamWriter new client; if (argc != 2) { printf ("Usage: ip6writer <server_hostname>\n"); } client openOn argv[1]; if (ex pending) { ex handle; } client writeText msg; client closeSock; }
sock
An Integer
that contains the system-assigned file handle number
of TCPIPV6NetworkStreamReader
and
TCPIPV6NetworkStreamWriter
objects.
addrInfo (String
hostname, String
canonnameout, List
addrsOut)
Performs a lookup of hostname’s IPv6 addresses. If the lookup
is successful, returns the host’s canonical name in canonnameout
and each of the host’s addresses as a string in addrsOut. The
method’s return value is an Integer
with the number of
addresses found.
If the lookup causes an error, the method raises an Exception
(not a SystemErrnoException
) and returns 0.
closeSock
(void
)
closeSock
(Integer
sockNum)
With no arguments, closes the receiver’s socket. If a socket file
handle number is given as the argument, closes that socket. If closing
the socket causes an error, the method raises a
SystemErrnoException
.
createSocketBasic
Creates a new IPv6 socket and sets the receiver’s sock
instance
variable, an Integer
, to the system-assigned file number, and
returns the sock
instance variable. If an error occurs while
creating a socket, the method raises a SystemErrnoException
and returns 0.
readText (void)
readText (Integer
sock_fn)
Read text from a network connection. With no arguments, the value
of the receiver’s sock
instance variable provides the socket
file handle. If one argument is given, the argument, an Integer
,
provides the file handle number.
These methods return a String
with the contents of the received
message. If an error occurs while reading, the methods raise a
SystemErrnoException
and return NULL
.
readVec (Integer
sock_fn, Vector
resultVec)
Reads binary data from the socket handle sock_fn into
resultVec, and returns resultVec. The method raises
a SystemErrnoException
if an error occurs.
writeText (String
textArg)
Writes the String
given as the argument to the
receiver’s socket. If the number of bytes written does not
match the length of textArg, the method raises a
SystemErrnoException
.
writeVec (Vector
dataVec)
Writes the contents of DATAVEC to the receiver’s socket. If
the number of bytes written does not match the length of the data,
the method raises a SystemErrnoException
.
Next: TCPIPV6NetworkStreamReader, Previous: TCPIPNetworkStreamWriter, Up: Classes [Index]