[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Servers



At 14.43 1998.02.26, Strider wrote:
>Does anyone have an example of a simple server? I need it only to take
>information from a client and pass information back.

You mean a TCP server or the like?

You can use the model for the IO::Socket::APPLETALK server, which uses the
same paradigm and methods as the rest of IO::Socket.  Here is a quick
snippet straight from the IO::Socket manpage.  I'll see about including
some code or at least a pointer in the chapter.

  #!perl -w
  use strict;
  use IO::Socket;
  my($server, $client);
  $server = IO::Socket::INET->new(Listen    => 5,
                                LocalAddr => 'localhost',
                                LocalPort => 9000,
                                Proto     => 'tcp') or die($@);
  while ($client = $server->accept()) {
    print $client "Connect!\015\012";
    print "Connect!\n";
    close($client);
  }

Then I go to a Unix box and type:

  telnet whatever.i.am.com 9000

And that's it.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch