NET-SERVER(1)

πŸ¦‹ NET-SERVER(1) πŸ¦‹

okay so bestie, buckle up β€” this is the manual page for net-server, straight out of the User Contributed Perl Documentation collection, and honestly? it's giving "tiny tool, big energy." πŸ’…

✨ NAME ✨

net-server β€” the base Net::Server starting module. that's it, that's the whole name section. iconic of it. πŸŽ€

🌸 SYNOPSIS 🌸

here's the shape of the thing, copied exactly because duh:

net-server [base type] [net server arguments]

net-server PreFork ipv '*'

net-server HTTP

net-server HTTP app foo.cgi

net-server HTTP app foo.cgi app /=bar.cgi

net-server HTTP port 8080 port 8443/ssl ipv '*' server_type PreFork --SSL_key_file=my.key --SSL_cert_file=my.crt access_log_file STDERR

like, look at that last one. it's a whole mood. πŸ”₯

πŸ’– DESCRIPTION πŸ’–

so the net-server program is literally just a super simple way to test out code and try out port connection parameters. that's its whole job and it does it well.

now, ngl, the running server can be robust enough for production β€” no cap β€” but the expectation is that this binary is gonna be used for:

  • basic testing of net-server ports
  • acting as a simple echo server
  • running development scripts as CGI

lowkey humble, highkey useful. 🫢


πŸ‘‘ OPTIONS πŸ‘‘

πŸ’œ base type

the very first argument can be a Net::Server flavor. this is basically shorthand so you don't have to write out server_type "ServerFlavor" yourself β€” we love a shortcut.

plus, this trick lets types like HTTP and PSGI β€” which are not true Net::Server base types β€” subclass other server types by passing an extra server_type argument. sneaky? a little. slay? absolutely.

net-server PreFork

net-server HTTP  # becomes a HTTP server in the Fork flavor

net-server HTTP server_type PreFork  # preforking HTTP server

πŸ“ port

the port to bind upon. and here's where the defaults get kinda specific, so listen up:

  • default is 80 if you're running a HTTP server as root
  • default is 8080 if you're running a HTTP server as non-root
  • default is 20203 otherwise

you can give multiple values to bind to multiple ports, which is honestly so extra in the best way. and every single method for specifying port attributes that's enumerated in Net::Server and Net::Server::Proto? all available here. all of them. 😭

net-server port 20201

net-server port 20202

net-server port 20203/IPv6

🌈 host

the host to bind to. default is *.

here's the vibe check on how it picks a socket:

  • give it an IPv4 address β†’ it binds to an IPv4 socket
  • give it an IPv6 address β†’ it binds to an IPv6 socket (this one requires installation of IO::Socket::INET6, fyi)
  • give it a hostname and ipv is still set to 4 β†’ IPv4 socket gets created
  • give it a hostname and ipv is set to 6 β†’ IPv6 socket gets created
  • give it a hostname and ipv is set to * (the default) β†’ a lookup happens and any available IPv4 or IPv6 addresses get bound

and the ipv parameter can be set directly, or passed along in the port, or passed as part of the hostname. three whole ways. choose your fighter. πŸ’€

net-server host localhost

net-server host localhost/IPv4

⭐ bestie, there are many more options available. please see the Net::Server documentation β€” this page is not the whole story, it's like the trailer. 🧚

πŸ’… AUTHOR πŸ’…

Paul Seamons <paul@seamons.com> β€” we stan. πŸ‘‘

🌟 LICENSE 🌟

this package may be distributed under the terms of either of these two:

  • GNU General Public License
  • or the Perl Artistic License

pick your poison, both are valid. πŸ¦‹


and that's a wrap, bestie πŸ’œ this page was brought to you by perl v5.42.0, dated 2023-03-15 β€” go forth and bind some ports, fr fr 🌸

πŸ“¦ where this page comes from