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