[Top] [Prev] [Next] [Bottom]


[Contents] [Index]

ip - TCP, UDP network protocols over IP

bind -a '#I' /net

/net/tcp/clone
/net/tcp/<n>
/net/tcp/<n>/data
/net/tcp/<n>/ctl
/net/tcp/<n>/local
/net/tcp/<n>/remote
/net/tcp/<n>/status
/net/tcp/<n>/listen
...

Description

The IP device provides the interface for protocols that run over IP. TCP and UDP provide the standard internet protocols for reliable stream and unreliable datagram communication.

Each of the protocols is served by the IP device, which represents each connection by a set of device files. The top level directory of each protocol contains a clone file and subdirectories numbered from 0 to the number of connections configured for this protocol.
clone Opening the clone file reserves a connection. The file descriptor returned from the open call points to the control file, ctl, of the newly allocated connection.
ctl Reading the ctl file returns a text string representing the number of the connection. Connections may be used either to listen for incoming calls or to initiate calls to other machines. A connection is controlled by writing text strings to the associated ctl file.
data After a connection has been established data may be read from and written to the data file. For the datagram service UDP, a read of less than the length of a datagram causes the entire datagram to be consumed. Each write to the data file sends a single datagram on the network. The TCP protocol provides a stream connection that does not preserve read/write boundaries.

Prior to sending data, remote and local addresses must be set for the connection. For outgoing calls the local port number will be allocated randomly if none is set. Addresses are set by writing control messages to the ctl file of the connection. The connection is not established until the data file is opened. For TCP, the process will block until the remote host has acknowledged the connection. UDP opens always succeed.

Control messages

The following control messages are supported:

connect

connect ipaddress! port [!r]

Set the remote IP address and port number for the connection. If the r flag is supplied and no local address has been specified the system allocates a restricted port number (less than 1024) for the connection to allow communication with Unix machines' login and exec services.

announce

announce X

X is a decimal port number or *. Set the local port number to X and accept calls to X. If X is *, accept calls for any port that no process has explicitly announced. The local IP address cannot be set. The announce attempt fails if the connection is already announced or connected.

bind

bind X

X is a decimal port number or *. Set the local port number to X. This exists to support emulation of BSD sockets and is not used otherwise.

hangup

hangup

Terminate the connection.

header (UDP only)

header

Skip headers on reads and writes.

linger

Controls the action taken when unsent data is queued on a connection and the connection is closed. Write to the ctl file one of the following:
linger -1

Sets default Inferno behavior (linger set to 1000 seconds).
linger 0

Discards unsent packets on close with immediate return.
linger X

For X > 0, attempts to send for X seconds, and returns upon completion or timeout.

If linger is set, the words linger X, where X > 0, should appear in the status file.

rcvtimeo (TCP only)

rcvtimeo X
For X > 0, set the timeout for reads to X seconds. If a read has timed out, the word timed-out should appear in the status file.

tcp_nodelay (TCP only)

tcp_nodelay
Sets no delay (on transmission of data) for TCP connections.

Notes

Port numbers must be in the range 1 to 32767. If a local port has not been announced prior to a connect a local port number is automatically allocated. Local ports are numbers greater than or equal to 5000.

Several files report the status of a connection.
remote The remote file provides the IP address and port number for the remote side of the connection.
local The local files contain the IP address and port number for the local side of the connection.
status The status file contains protocol-dependent information to help debug network connections.
listen A process may accept incoming connections by opening the listen file. The open will block until a new connection request arrives. Then open will return an open file descriptor that points to the control file of the newly accepted connection. This procedure accepts all calls for the given protocol.

The dial, announce, and listen functions in the Sys module provide an alternate method to perform the necessary I/O to establish and manipulate network connections. The operation of the ip device is transparent to users of the Sys module.

See Also

dial, announce, export, listen - network connections in Chapter 8



[Top] [Prev] [Next] [Bottom]

infernosupport@lucent.com
Copyright © 1997, Lucent Technologies, Inc.. All rights reserved.