Learn R Programming

⚠️There's a newer version (0.1.2) of this package.Take me there.

The Netstat Package

netstat allows you to easily view which TCP ports are in use and which are free to use.

Load library

# library(devtools)
# install_github("stevecondylios/netstat")
library(netstat)

See which TCP ports are in use

ports_in_use()
##  [1] "46915" "57416" "34403" "57403" "57399" "57398" "1538"  "57194"
##  [9] "57191" "57190" "56557" "57188" "57187" "57184" "57183" "56558"
## [17] "55205" "16233" "63415" "13287" "*"     "61348" "1025"  "1024" 
## [25] "55651" "51313" "63238" "58336" "56395" "45112" "30666" "58154"
## [33] "50712" "65415" "65413" "63546" "57146" "56677" "49445" "5432" 
## [41] "49160" "49155" "49157" "49156" "49154" "49153" "57414" "62782"
## [49] "64779" "5353"  "3722"  "50695" "59848" "58010" "55522" "57882"
## [57] "55719" "59190" "59189" "138"   "137"

Find a free TCP port using free_port().

free_port()
## [1] 14415
free_port(random=T)
## [1] 11195
  • free_port() returns a TCP port from Internet Assigned Numbers Authority (IANA) listed unassigned ports.

  • Any TCP port being used by the local machine will not be returned (so free_port() can be used to allocate a free port programmatically in applications without collisions)

Copy Link

Version

Install

install.packages('netstat')

Monthly Downloads

1,776

Version

0.1.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Steve Condylios

Last Published

January 23rd, 2020

Functions in netstat (0.1.1)

parse_netstat

Parse the output of the 'Netstat' command line utility - obtained via netstat()
free_port

Retrieve a Transmission Control Protocol (TCP) port that is not currently in use
netstat-package

Retrieve Network Statistics Including Available TCP Ports
free_ports

Retrieve many (not all) Transmission Control Protocol (TCP) ports that are not currently in use
netstat

Retrieve the output of the 'netstat' command line utility
unassigned_ports

Obtain a list of the largest ranges of unassigned Transmission Control Protocol (TCP) ports as provided by the Internet Assigned Numbers Authority (IANA)
ports_in_use

Obtain the TCP ports currently in use