Listen on port – client server demo

Problem

You want to listen on a port, maybe to test firewalls! ๐Ÿ™‚

Excellent introduction to client server software.



Solution

Another use bit of socket programming, courtesy of Perl! ๐Ÿ™‚

Extremely useful bit of Perl, which can be used with the other post on this site, to confirm network connectivity (port scanner).

This code (see example tab) will listen on a port (although be careful it is over 1024, unless you are running as root/admin).



Example



perl -MIO::Socket -e '$srv=IO::Socket::INET->
new(LocalPort=>$ARGV[0],Type=>SOCK_STREAM,Reuse=>1,Listen=>5)

or die "Failed trying to listen on $ARGV[0]n";while($cl=$srv->accept()) { while() { print }

} close($socket);' port

Can also use it as a cheap chat service! ๐Ÿ™‚ Everything gets echo'd through – so just telnet host port and type away! ๐Ÿ™‚

Also see my port scan code at the reference tab.



Reference

[tags]Perl Socket Programming, Network Programming, Perl Port Listen, Perl Client Server demo, Perl Coding School[/tags]



Comment (1)

  1. […] Perl Coding School ยป Listen on port – client server demo (tags: Perl Socket Network Programming Port Listener Client Server demo Coding School) Subscribe to techie blogs central by Email […]

Leave a Reply

Your email address will not be published. Required fields are marked *