xref: /netbsd/usr.bin/sockstat/sockstat.1 (revision 6550d01e)
1.\"	$NetBSD: sockstat.1,v 1.7 2008/05/04 19:43:06 martin Exp $
2.\"-
3.\" Copyright (c) 2005 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Andrew Brown.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" Copyright (c) 1999 Dag-Erling Co�dan Sm�rgrav
31.\" All rights reserved.
32.\"
33.\" Redistribution and use in source and binary forms, with or without
34.\" modification, are permitted provided that the following conditions
35.\" are met:
36.\" 1. Redistributions of source code must retain the above copyright
37.\"    notice, this list of conditions and the following disclaimer
38.\"    in this position and unchanged.
39.\" 2. Redistributions in binary form must reproduce the above copyright
40.\"    notice, this list of conditions and the following disclaimer in the
41.\"    documentation and/or other materials provided with the distribution.
42.\" 3. The name of the author may not be used to endorse or promote products
43.\"    derived from this software without specific prior written permission.
44.\"
45.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
46.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
49.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55.\"
56.\" FreeBSD: src/usr.bin/sockstat/sockstat.1,v 1.19 2004/08/25 16:36:17 roam Exp
57.\"
58.Dd July 14, 2006
59.Dt SOCKSTAT 1
60.Os
61.Sh NAME
62.Nm sockstat
63.Nd list open sockets
64.Sh SYNOPSIS
65.Nm
66.Op Fl 46clnu
67.Op Fl f Ar address_family
68.Op Fl p Ar ports
69.Sh DESCRIPTION
70The
71.Nm
72command lists open Internet or
73.Ux
74domain sockets.
75.Pp
76The following options are available:
77.Bl -tag -width Fl
78.It Fl 4
79Show
80.Dv AF_INET
81(IPv4) sockets.
82.It Fl 6
83Show
84.Dv AF_INET6
85(IPv6) sockets.
86.It Fl c
87Show connected sockets.
88.It Fl f Ar address_family
89Limit listed sockets to those of the specified
90.Ar address_family .
91The following address families
92are recognized:
93.Ar inet ,
94for
95.Dv AF_INET ;
96.Ar inet6 ,
97for
98.Dv AF_INET6 ;
99and
100.Ar local
101or
102.Ar unix ,
103for
104.Dv AF_LOCAL .
105.It Fl l
106Show listening sockets.
107.It Fl n
108Numeric output only.
109No attempt will be made to look up symbolic names for addresses
110and ports.
111.It Fl p Ar ports
112Only show Internet sockets if either the local or foreign port number
113is on the specified list.
114The
115.Ar ports
116argument is a comma-separated list of port numbers and ranges
117specified as first and last port separated by a dash.
118.It Fl u
119Show
120.Dv AF_LOCAL
121.Pq Ux
122sockets.
123.El
124.Pp
125If neither
126.Fl 4 , 6 ,
127nor
128.Fl u
129are specified,
130.Nm
131will list sockets in all three domains.
132.Pp
133If neither
134.Fl c
135nor
136.Fl l
137are specified,
138.Nm
139will list both listening and connected sockets, as well as those
140sockets that are in neither state.
141.Pp
142The information listed for each
143socket is:
144.Bl -tag -width "FOREIGN ADDRESS"
145.It Li USER
146The user who owns the socket.
147.It Li COMMAND
148The command which holds the socket.
149.It Li PID
150The process ID of the command which holds the socket.
151.It Li FD
152The file descriptor number of the socket.
153.It Li PROTO
154The transport protocol associated with the socket for Internet
155sockets, or the type of socket (stream or datagram) for
156.Ux
157sockets.
158.It Li LOCAL ADDRESS
159For Internet sockets, this is the address to which the local end
160of the socket is bound (see
161.Xr getsockname 2 ) .
162For bound
163.Ux
164sockets, it is the socket's filename or
165.Dq - .
166.It Li FOREIGN ADDRESS
167The address to which the foreign end of the socket is bound (see
168.Xr getpeername 2 )
169or
170.Dq -
171for unconnected
172.Ux
173sockets.
174.El
175.Sh SEE ALSO
176.Xr fstat 1 ,
177.Xr netstat 1 ,
178.Xr inet 4 ,
179.Xr inet6 4 ,
180.Xr unix 4
181.Sh HISTORY
182The
183.Nm
184command appeared in
185.Fx 3.1 .
186It was then rewritten for
187.Nx 3.0 .
188.Sh AUTHORS
189.An -nosplit
190This version of the
191.Nm
192command was written by
193.An Andrew Brown
194.Aq atatat@NetBSD.org .
195This manual page was written by
196.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
197and was adapted to match the
198.Nx
199implementation by
200.An Andrew Brown
201.Aq atatat@NetBSD.org .
202