Professional Web Applications Themes

server is numb? - PERL Beginners

Hello together, I just tryed to make a simple Socket-Connection with a client and a server which are connected with each other over localhost. the server: #!/usr/bin/perl use IO::Socket; use strict; my $server_port = 3434; my $server; my $client; my $in_line; $server = IO::Socket::INET-> new ( LocalPort => $server_port, Type => SOCK_STREAM, Reuse => 1, Listen => SOMAXCONN ) or die "unable to start server ! $\n"; while ( $client = $server->accept () ) { $in_line = <CLIENT>; print "$in_line \n"; } close ( $server ); __END_ and the client: #!/usr/bin/perl use IO::Socket; use strict; my $remote_host = "localhost"; my ...

  1. #1

    Default server is numb?

    Hello together,
    I just tryed to make a simple Socket-Connection with a client and a server
    which are connected with each other over localhost.

    the server:
    #!/usr/bin/perl

    use IO::Socket;
    use strict;

    my $server_port = 3434;
    my $server;
    my $client;
    my $in_line;

    $server = IO::Socket::INET-> new ( LocalPort => $server_port,
    Type => SOCK_STREAM,
    Reuse => 1,
    Listen => SOMAXCONN )
    or die "unable to start server ! $\n";


    while ( $client = $server->accept () )
    {
    $in_line = <CLIENT>;
    print "$in_line \n";
    }

    close ( $server );
    __END_

    and the client:

    #!/usr/bin/perl

    use IO::Socket;
    use strict;

    my $remote_host = "localhost";
    my $remote_port = 3434;
    my $socket;
    my $data = "test";

    $socket = IO::Socket::INET->new ( PeerAddr => $remote_host,
    PeerPort => $remote_port,
    Proto => "tcp",
    Type => SOCK_STREAM )
    or die "unable to establishe a connection !\n";

    $socket-> send ( $data , $flags ) or die "could not send!\n";

    close ( $socket );

    __END_

    I expact, that the data-string is send by the client to the server. When it
    reaches the server, the server put it out, and keep on listening.

    But the server does nothing at all, its numb?!?

    What did I omitted? How I get the flags? With fcntl ?

    Gruss Christian
    Christian Guest

  2. #2

    Default Re: server is numb?

    Okay okay, it shold call:
    while ( $client = $server->accept () )
    {
    print "$client \n";
    }
    close ( $server );
    __END_

    And so it works, but not as I need. The output is
    IO::Socket::INET=GLOB(0x81848d0)

    Gruss Christian


    --
    Christian Stalp

    Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI)
    Obere Zahlbacher Straße 69
    55131 Mainz
    Tel.: 06131/ 17-6852

    E-Mail: uni-mainz.de
    Internet: www.imbei.de
    Christian Guest

  3. #3

    Default Re: server is numb?

    On Sep 28, Christian Stalp said:
     

    To send data to the socket, just print() to it:

    print $socket "$data\n";

    --
    Jeff "japhy" Pinyan % How can we ever be the sold short or
    RPI Acacia Brother #734 % the cheated, we who for every service
    http://japhy.perlmonk.org/ % have long ago been overpaid?
    http://www.perlmonks.org/ % -- Meister Eckhart

    Jeff Guest

Similar Threads

  1. Replies: 0
    Last Post: August 15th, 09:24 AM
  2. Replies: 2
    Last Post: September 12th, 10:44 PM
  3. Replies: 0
    Last Post: August 23rd, 05:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139