1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
.\" -*- nroff -*-
.ig
$Header: socket.1[1.13] Wed Sep 9 16:46:30 1992 nickel@cs.tu-berlin.de proposed $
This file is part of socket(1).
Copyright (C) 1992 by Juergen Nickelsen <nickel@cs.tu-berlin.de>
Please read the file COPYRIGHT for further details.
..
.TH SOCKET 1 "Aug 6, 1992"
.SH NAME
socket \- create a TCP or a UNIX domain socket and connect to stdin/out
.SH SYNOPSIS
.B socket
[
.B \-bcfqrvw
]
[
.B \-p
.I command
]
[
.B \-B
.I local address
]
.I host port
.br
.B socket
[
.B \-bcfqrvw
]
[
.B \-p
.I command
]
.I /path
.br
.B socket
[
.B \-bcfqrvw
]
[
.B \-p
.I command
]
[
.B \-B
.I local address
]
.B \-s
[
.B \-l
]
.I port
.br
.B socket
[
.B \-bcfqrvw
]
[
.B \-p
.I command
]
.B \-s
[
.B \-l
]
.I /path
.SH DESCRIPTION
.B Socket
creates an Internet domain TCP or a UNIX domain stream socket and connects it to stdin and stdout.
The
.I host
argument can be an Internet number in dot-notation (like
``130.149.28.10'') or a domain name. In this case it must be possible
to resolve the name to a valid Internet address with
.IR gethostbyname (3).
The
.I port
argument can be a port number or a service name which can be mapped to
a port number by
.IR getservbyname (3).
If an UNIX domain socket is wanted to be created instead of an Internet
socket, specify the
.I path
instead of an internet (canonical domain named or dot-notated) host.
The hostname is treated as a pathname if contains at least a single
slash. I.e. if one wants to create or connect to a socket in the current
directory, use
.I ./filename
to specify the connection point.
.SH OPTIONS
.TP
.BR "\-b " (background)
The program forks itself into the background, detaches from its
controlling tty, closes the file descriptors associated with the tty,
and changes its current directory to the root directory.
.TP
.BR "\-B " "(local address)"
This option specifies which
.I local address
to binded to when making a connection.
.TP
.BR "\-c " (crlf)
Linefeed characters (LF) are converted to a Carriage Return Linefeed
sequence (CRLF) when written to the socket.
CRLF sequences read from the socket are converted to a single LF.
.TP
.BR "\-f " (fork)
When a server connection has been accepted, a separate process is
forked to handle the connection in background.
.TP
.BR "\-l " (loop)
(only valid with
.BR \-s )
After a connection has been closed,
another connection is accepted.
.TP
.BR "\-p " (program)
The specified
.I command
is executed for each connection. Its standard input, standard output,
and standard error channels are connected to the socket.
.I Command
can be any shell command since it is passed to \fC/bin/sh\fP.
.TP
.BR "\-q " (quit)
The connection is closed when an end-of-file condition occurs on standard
input.
.TP
.BR "\-r " "(read only)"
No data is read from standard input and written to the socket.
.TP
.BR "\-s " (server)
A server socket is created.
A
.I hostname
argument is not required of Internet sockets, only the port number
but a pathname is required for UNIX domain sockets.
.TP
.BR "\-v " (verbose)
Messages about connections etc. are issued to stderr.
.TP
.BR "\-w " "(write only)"
No data is read from the socket and written to the standard output.
.TP
.B \-version
.B Socket
prints its version ID and terminates.
This must be the first argument to have an effect.
.SH EXAMPLES
The command
.IP
\fCsocket -v coma.cs.tu-berlin.de nntp\fP
.LP
connects to the nntp port (port 119) of coma.cs.tu-berlin.de
(130.149.28.10).
.br
The command
.IP
\fCsocket \-sl 3425\fP
.LP
creates a server socket on port 3425 on the local host and waits for a
connection.
After a connection has been closed, a new connection is accepted.
.br
The command
.IP
\fCsocket \-wslqvp "echo Socket! " 1938\fP
.LP
creates a server socket on port 1938 on the local host and waits for a
connection.
When a connection is accepted, the string "Socket!" is written to the
socket.
No data is read from the socket and written to the \fCfinger\fP
program.
The connection is closed when an end-of-file condition at the standard
output of the program occurs.
Then a new connection is accepted.
.SH DIAGNOSTICS
Lots of diagnostics for failed system calls.
.TP
.BI "unknown host " host
.IR host 's
address could not be resolved.
.TP
.B Signal \fIsignal\fP caught, exiting
.B Socket
exits on any signal other than SIGTSTP, SIGCONT, SIGCLD, SIGQUIT.
.LP
A non-zero exit code is returned if
.B socket
terminates due to an error condition or a signal.
.SH SEE ALSO
.BR ip (7),
.BR tcp (7),
.BR unix (7),
.BR accept (2),
.BR bind (2),
.BR listen (2),
.BR connect (2),
.BR socket (2),
.BR gethostbyname (3),
.BR getservbyname (3)
.SH BUGS
\fCsocket \-p\fP terminates due to a SIGPIPE signal when there is more
data from the socket available than the executed program wants to
read.
.LP
Please report any other bugs to the author.
.SH VERSION
This manual page describes Socket\-1.1.
.SH AUTHOR
Juergen Nickelsen <nickel@cs.tu-berlin.de>
|