1.\" $NetBSD: sockstat.1,v 1.5 2005/09/11 23:26:35 wiz 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 March 9, 2005 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 46clu 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 p Ar ports 111Only show Internet sockets if either the local or foreign port number 112is on the specified list. 113The 114.Ar ports 115argument is a comma-separated list of port numbers and ranges 116specified as first and last port separated by a dash. 117.It Fl u 118Show 119.Dv AF_LOCAL 120.Pq Ux 121sockets. 122.El 123.Pp 124If neither 125.Fl 4 , 6 , 126nor 127.Fl u 128are specified, 129.Nm 130will list sockets in all three domains. 131.Pp 132If neither 133.Fl c 134nor 135.Fl l 136are specified, 137.Nm 138will list both listening and connected sockets, as well as those 139sockets that are in neither state. 140.Pp 141The information listed for each 142socket is: 143.Bl -tag -width "FOREIGN ADDRESS" 144.It Li USER 145The user who owns the socket. 146.It Li COMMAND 147The command which holds the socket. 148.It Li PID 149The process ID of the command which holds the socket. 150.It Li FD 151The file descriptor number of the socket. 152.It Li PROTO 153The transport protocol associated with the socket for Internet 154sockets, or the type of socket (stream or datagram) for 155.Ux 156sockets. 157.It Li LOCAL ADDRESS 158For Internet sockets, this is the address to which the local end 159of the socket is bound (see 160.Xr getsockname 2 ) . 161For bound 162.Ux 163sockets, it is the socket's filename or 164.Dq - . 165.It Li FOREIGN ADDRESS 166The address to which the foreign end of the socket is bound (see 167.Xr getpeername 2 ) 168or 169.Dq - 170for unconnected 171.Ux 172sockets. 173.El 174.Sh SEE ALSO 175.Xr fstat 1 , 176.Xr netstat 1 , 177.Xr inet 4 , 178.Xr inet6 4 , 179.Xr unix 4 180.Sh HISTORY 181The 182.Nm 183command appeared in 184.Fx 3.1 . 185It was then rewritten for 186.Nx 3.0 . 187.Sh AUTHORS 188.An -nosplit 189This version of the 190.Nm 191command was written by 192.An Andrew Brown 193.Aq atatat@NetBSD.org . 194This manual page was written by 195.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org 196and was adapted to match the 197.Nx 198implementation by 199.An Andrew Brown 200.Aq atatat@NetBSD.org . 201