use Socket;
socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1);
$addr = sockaddr_in(2336, inet_aton('server.com'));
bind(SERVER, $addr) or die "Could not bind to port.\n";
listen(SERVER, SOMAXCONN) or die "Could not listen to port.\n";
while (accept(CLIENT, SERVER)) {
print CLIENT "Hello from the server!\n";
}
close(SERVER);
|