Server Implementation
To enable clients to connect to them, servers must specify:
A protocol with which to communicate
A port number
Use the
IO::Socket
module:
Documented as
perlipc
IPC is interprocess communication:
Signals, fifos, pipes, safe subprocesses, sockets, and semaphores
Example of enabling clients to connect:
use IO::Socket;
$server = IO::Socket::INET->new(
Proto => 'tcp',
LocalPort => 9000,
Listen => SOMAXCONN,
Reuse => 1
);
LocalPort
: Port numbers are standardized server IDs. Examples:
Port
Protocol
Service
13
daytime
time of day
21
ftp
file transfer
23
telnet
remote login
42
name
nameserver
43
whois
domain lookup
110
pop3
Post Office Protocol
119
nntp
Usenet news transfer
2049
NFS
Network File System
Port numbers below 1024 are reserved.
Listen
: How many connections your server can queue before turning requests away.
SOMAXCONN
is the highest number for your system.
Reuse
: When TRUE, the server can restart without waiting for cleanup from the last server on this port.
Frequently-used methods for servers