previous | start | next

Sockets in Other Languages

The Perl programming language has become very popular in recent years. It's interesting to compare a Perl client program with the Java program from earlier:
#!/usr/local/bin/perl
use IO::Socket::INET;

$sock = IO::Socket::INET->new(PeerAddr => 'ironbark',
                              PeerPort => 'finger(79)',
                              Proto    => 'tcp');
print $sock "pscott\n";

while(<$sock>) {
    print;
}
On the other hand, a C program to perform the same function (actually it does a little more, but we won't quibble...) is about 70 lines, not including comments!
 
Lecture 8: Socket Programming Interface Copyright © 2002 P.Scott, La Trobe University Bendigo.



previous | start | next