Next: , Previous: , Up: Classes   [Index]


TCPIPNetworkStreamReader

TCPIPNetworkStreamReader Class

TCPIPNetworkStreamReader class defines methods and instance variables that are used specifically for reading data from network connections.

For example programs, refer to the TCPIPNetworkStream class See TCPIPNetworkStream.

Instance Variables

timeout

An Integer that contains the number of seconds to wait for incoming connections.

Instance Methods

acceptSock (void)

Waits for an incoming connection on the receiver’s socket, and if a connection is pending, returns the number of the socket that communications will take place on.

If the connection times out, then the method returns 0. The length of time the method should wait for incoming connections is given by the receiver’s timeout instance variable.

If an error occurs, the method returns 0 and also raises a SystemErrnoException.

Note: The method can handle peer connections if the operating system supports it - binding listening sockets to specific addresses is not uniformly supported among operating systems. In these cases, the method can also wait for connections using the constant INADDR_ANY.

This is done by using the openOn method (below) with no network address.


  mySock openOn "127.0.0.1";   /* bind the socket to the
                                  local network connection. */
     
  mySock openOn;               /* bind a socket to listen for
                                  connections from any network
                                  address. */

In the second case, the acceptSock method can also function as the core of a more conventional network server.

openOn (void)
openOn (String address)
openOn (String address, Integer port)

Creates the receiver’s socket and binds it to receive messages from the network address given as the argument. If no network address is given, the receiver’s socket is bound to the constant INADDR_ANY.

If no port argument is given, the socket is bound to DEFAULT_TCPIP_PORT, which is defined in classes/ctalkdefs.h, and which you can set depending on the the systems’ needs.

These methods raise an Exception if any of the networking functions return an error.


Next: , Previous: , Up: Classes   [Index]