xref: /freebsd/usr.bin/sockstat/sockstat.1 (revision e4e9813eb92cd7c4d4b819a8fbed5cbd3d92f5d8)
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 August 25, 2004
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.Sh DESCRIPTION
41The
42.Nm
43command lists open Internet or
44.Ux
45domain sockets.
46.Pp
47The following options are available:
48.Bl -tag -width Fl
49.It Fl 4
50Show
51.Dv AF_INET
52(IPv4) sockets.
53.It Fl 6
54Show
55.Dv AF_INET6
56(IPv6) sockets.
57.It Fl c
58Show connected sockets.
59.It Fl l
60Show listening sockets.
61.It Fl p Ar ports
62Only show Internet sockets if either the local or foreign port number
63is on the specified list.
64The
65.Ar ports
66argument is a comma-separated list of port numbers and ranges
67specified as first and last port separated by a dash.
68.It Fl u
69Show
70.Dv AF_LOCAL
71.Pq Ux
72sockets.
73.El
74.Pp
75If neither
76.Fl 4 , 6
77or
78.Fl u
79is specified,
80.Nm
81will list sockets in all three domains.
82.Pp
83If neither
84.Fl c
85or
86.Fl l
87is specified,
88.Nm
89will list both listening and connected sockets.
90.Pp
91The information listed for each
92socket is:
93.Bl -tag -width "FOREIGN ADDRESS"
94.It Li USER
95The user who owns the socket.
96.It Li COMMAND
97The command which holds the socket.
98.It Li PID
99The process ID of the command which holds the socket.
100.It Li FD
101The file descriptor number of the socket.
102.It Li PROTO
103The transport protocol associated with the socket for Internet
104sockets, or the type of socket (stream or datagram) for
105.Ux
106sockets.
107.It Li LOCAL ADDRESS
108For Internet sockets, this is the address the local end of the socket
109is bound to (see
110.Xr getsockname 2 ) .
111For bound
112.Ux
113sockets, it is the socket's filename.
114For other
115.Ux
116sockets, it is a right arrow followed by the endpoint's filename, or
117.Dq Li ??
118if the endpoint could not be determined.
119.It Li FOREIGN ADDRESS
120(Internet sockets only)
121The address the foreign end of the socket is bound to (see
122.Xr getpeername 2 ) .
123.El
124.Pp
125Note that TCP sockets in the
126.Dv AF_INET
127or
128.Dv AF_INET6
129domains that are not in one of the
130.Dv LISTEN , SYN_SENT ,
131or
132.Dv ESTABLISHED
133states may not be shown by
134.Nm ;
135use
136.Xr netstat 1
137to examine them instead.
138.Sh SEE ALSO
139.Xr fstat 1 ,
140.Xr netstat 1 ,
141.Xr inet 4 ,
142.Xr inet6 4
143.Sh HISTORY
144The
145.Nm
146command appeared in
147.Fx 3.1 .
148.Sh AUTHORS
149The
150.Nm
151command and this manual page were written by
152.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
153