xref: /freebsd/usr.bin/sockstat/sockstat.1 (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1.\"-
2.\" Copyright (c) 1999 Dag-Erling Co�dan Sm�rgrav
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer
10.\"    in this position and unchanged.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\"    derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $FreeBSD$
29.\"
30.Dd November 11, 2006
31.Dt SOCKSTAT 1
32.Os
33.Sh NAME
34.Nm sockstat
35.Nd list open sockets
36.Sh SYNOPSIS
37.Nm
38.Op Fl 46clu
39.Op Fl p Ar ports
40.Op Fl P Ar protocols
41.Sh DESCRIPTION
42The
43.Nm
44command lists open Internet or
45.Ux
46domain sockets.
47.Pp
48The following options are available:
49.Bl -tag -width Fl
50.It Fl 4
51Show
52.Dv AF_INET
53(IPv4) sockets.
54.It Fl 6
55Show
56.Dv AF_INET6
57(IPv6) sockets.
58.It Fl c
59Show connected sockets.
60.It Fl l
61Show listening sockets.
62.It Fl p Ar ports
63Only show Internet sockets if either the local or foreign port number
64is on the specified list.
65The
66.Ar ports
67argument is a comma-separated list of port numbers and ranges
68specified as first and last port separated by a dash.
69.It Fl P Ar protocols
70Only show sockets of the specified
71.Ar protocols .
72The
73.Ar protocols
74argument is a comma-separated list of protocol names,
75as they are defined in
76.Xr protocols 5 .
77.It Fl u
78Show
79.Dv AF_LOCAL
80.Pq Ux
81sockets.
82.El
83.Pp
84If neither
85.Fl 4 , 6
86or
87.Fl u
88is specified,
89.Nm
90will list sockets in all three domains.
91.Pp
92If neither
93.Fl c
94or
95.Fl l
96is specified,
97.Nm
98will list both listening and connected sockets.
99.Pp
100The information listed for each
101socket is:
102.Bl -tag -width "FOREIGN ADDRESS"
103.It Li USER
104The user who owns the socket.
105.It Li COMMAND
106The command which holds the socket.
107.It Li PID
108The process ID of the command which holds the socket.
109.It Li FD
110The file descriptor number of the socket.
111.It Li PROTO
112The transport protocol associated with the socket for Internet
113sockets, or the type of socket (stream or datagram) for
114.Ux
115sockets.
116.It Li LOCAL ADDRESS
117For Internet sockets, this is the address the local end of the socket
118is bound to (see
119.Xr getsockname 2 ) .
120For bound
121.Ux
122sockets, it is the socket's filename.
123For other
124.Ux
125sockets, it is a right arrow followed by the endpoint's filename, or
126.Dq Li ??
127if the endpoint could not be determined.
128.It Li FOREIGN ADDRESS
129(Internet sockets only)
130The address the foreign end of the socket is bound to (see
131.Xr getpeername 2 ) .
132.El
133.Pp
134Note that TCP sockets in the
135.Dv AF_INET
136or
137.Dv AF_INET6
138domains that are not in one of the
139.Dv LISTEN , SYN_SENT ,
140or
141.Dv ESTABLISHED
142states may not be shown by
143.Nm ;
144use
145.Xr netstat 1
146to examine them instead.
147.Sh SEE ALSO
148.Xr fstat 1 ,
149.Xr netstat 1 ,
150.Xr inet 4 ,
151.Xr inet6 4 ,
152.Xr protocols 5
153.Sh HISTORY
154The
155.Nm
156command appeared in
157.Fx 3.1 .
158.Sh AUTHORS
159The
160.Nm
161command and this manual page were written by
162.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
163