… | |
… | |
466 | address and port number of the local socket endpoint as second and third |
466 | address and port number of the local socket endpoint as second and third |
467 | arguments. |
467 | arguments. |
468 | |
468 | |
469 | It should return the length of the listen queue (or C<0> for the default). |
469 | It should return the length of the listen queue (or C<0> for the default). |
470 | |
470 | |
471 | Example: bind on TCP port 8888 on the local machine and tell each client |
471 | Example: bind on some TCP port on the local machine and tell each client |
472 | to go away. |
472 | to go away. |
473 | |
473 | |
474 | tcp_server undef, 8888, sub { |
474 | tcp_server undef, undef, sub { |
475 | my ($fh, $host, $port) = @_; |
475 | my ($fh, $host, $port) = @_; |
476 | |
476 | |
477 | syswrite $fh, "The internet is full, $host:$port. Go away!\015\012"; |
477 | syswrite $fh, "The internet is full, $host:$port. Go away!\015\012"; |
|
|
478 | }, sub { |
|
|
479 | my ($fh, $thishost, $thisport) = @_; |
|
|
480 | warn "bound to $thishost, port $thisport\n"; |
478 | }; |
481 | }; |
479 | |
482 | |
480 | =cut |
483 | =cut |
481 | |
484 | |
482 | sub tcp_server($$$;$) { |
485 | sub tcp_server($$$;$) { |