|
|
1.1 ! root 1: .TH TCP 3X ! 2: .CT 2 comm_mach ! 3: .SH NAME ! 4: tcp_sock, tcp_connect, tcp_listen, tcp_accept, tcp_rcmd \(mi tcp networking functions ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .B #include <sys/inet/tcp_user.h> ! 8: .PP ! 9: .B int tcp_sock(); ! 10: .PP ! 11: .B int tcp_connect(fd, tp) ! 12: .B int fd; ! 13: .B struct tcpuser *tp; ! 14: .PP ! 15: .B int tcp_listen(fd, tp) ! 16: .B int fd; ! 17: .B struct tcpuser *tp; ! 18: .PP ! 19: .B int tcp_accept(fd, tp) ! 20: .B int fd; ! 21: .B struct tcpuser *tp; ! 22: .PP ! 23: .B "int tcp_rcmd(host, port, locuser, remuser, cmd, fd2p)" ! 24: .B char *host, *port, *locuser, *remuser, *cmd; ! 25: .B int *fd2p; ! 26: .PP ! 27: .SH DESCRIPTION ! 28: These routines are loaded by the ! 29: .B -lin ! 30: option of ! 31: .IR ld (1). ! 32: .PP ! 33: TCP is a protocol layered ! 34: upon IP (internet protocol). ! 35: It provides full-duplex byte stream connections between ! 36: end points called sockets. ! 37: The address of a socket is composed of the internet address ! 38: of its host and the port number to which ! 39: the socket is bound. ! 40: .PP ! 41: .I Tcp_sock ! 42: returns the file descriptor of an unbound socket. ! 43: Once opened, a socket may be bound to a port number within the ! 44: host and set up as the active or passive end of a connection. ! 45: .PP ! 46: Addresses and parameters are passed in ! 47: .B tcpuser ! 48: structures: ! 49: .PP ! 50: .nf ! 51: .ft L ! 52: .ta 8n ! 53: struct tcpuser { ! 54: int code; ! 55: tcp_port lport, fport; ! 56: in_addr laddr, faddr; ! 57: int param; ! 58: }; ! 59: .fi ! 60: .ft R ! 61: .PP ! 62: .I Lport ! 63: and ! 64: .I laddr ! 65: refer to the port and address numbers of the local end of a connection. ! 66: .I Fport ! 67: and ! 68: .I faddr ! 69: refer to the port and address numbers of the foreign end of a connection. ! 70: .PP ! 71: .I Tcp_connect ! 72: binds socket ! 73: .I fd ! 74: to port ! 75: .IB tp ->lport ! 76: and attempts to set up a connection to ! 77: the socket bound to port ! 78: .IB tp ->fport ! 79: on host ! 80: .IB tp ->faddr. ! 81: If ! 82: .IB tp ->lport ! 83: is 0, a local port number is automatically ! 84: chosen. ! 85: .I Tcp_connect ! 86: returns 0 ! 87: if the connection is established, \-1 otherwise. ! 88: .IB Tp ->lport ! 89: and ! 90: .IB tp ->laddr ! 91: are filled in to reflect the local port and address numbers for the connection. ! 92: Communication proceeds by performing ! 93: .IR read (2) ! 94: and ! 95: .IR write ! 96: on ! 97: .IR fd . ! 98: If ! 99: .IB tp ->param ! 100: is non-zero, it specifies options to set for the connection. ! 101: The only option supported is ! 102: .B SO_KEEPALIVE ! 103: which causes empty messages to be sent periodically to ! 104: detect dead connections. ! 105: .PP ! 106: .I Tcp_listen ! 107: binds socket ! 108: .I fd ! 109: to port ! 110: .IB tp ->lport ! 111: and configures the socket to listen for connection requests to that port. ! 112: If ! 113: .IB tp ->faddr ! 114: and ! 115: .IB tp ->fport ! 116: are non-zero, only connections coming from sockets on machine ! 117: .I faddr ! 118: and bound to port ! 119: .I fport ! 120: are listened for. ! 121: .I Tcp_listen ! 122: returns 0 ! 123: on success, \-1 ! 124: otherwise. ! 125: .IB tp ->laddr ! 126: is filled in to reflect the local address number for the connection. ! 127: .IR Select (2) ! 128: can be used with a listening socket to provide asynchronous polling of ! 129: connection requests by selecting for pending input on the socket. ! 130: .PP ! 131: .I Tcp_accept ! 132: waits for and accepts a connection request sent to the listening socket ! 133: .I fd. ! 134: When a connection arrives, ! 135: .I tcp_accept ! 136: returns a new file descriptor over which communications can proceed. ! 137: .IB Tp ->faddr, ! 138: .IB tp ->fport, ! 139: .IB tp ->laddr, ! 140: and ! 141: .IB tp ->lport ! 142: are filled in to identify the two ends of the connection. ! 143: .IB Tp ->param ! 144: is filled in with the minor device number of the ! 145: tcp device used for the new connection. ! 146: .I Fd ! 147: is left open and continues listening for connections. ! 148: .PP ! 149: .I Tcp_rcmd ! 150: remotely executes a ! 151: .I cmd ! 152: on ! 153: .I host ! 154: as user ! 155: .I remuser. ! 156: Standard input is attached to ! 157: .I cmd's ! 158: standard input and ! 159: .I cmd's ! 160: standard output is attached to standard output. ! 161: If ! 162: .I fd2p ! 163: is non-zero, it is filled with the file descriptor of a new TCP connection attached ! 164: to ! 165: .I cmd's ! 166: standard error. ! 167: Otherwise, ! 168: .I cmd's ! 169: standard error is attached to its standard output. ! 170: .SH FILES ! 171: .TP 12 ! 172: .F /dev/tcp* ! 173: the socket devices ! 174: .SH SEE ALSO ! 175: .IR ipc (3), ! 176: .IR internet (3), ! 177: .IR udp (3) ! 178: .SH DIAGNOSTICS ! 179: .I Tcp_sock ! 180: returns \-1 ! 181: if no sockets are available.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.