Thread Socket Connect mit Perl: Socket Connect mit Perl (26 answers)
Opened by betterworld at 2004-07-19 17:34

esskar
 2004-07-20 13:22
#37376 #37376
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
aso...

okay... ich hack mal was runter

Code: (dl )
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
use strict;
use IO::Socket;
use IO::Socket::INET;

my $CRLF = chr(13).chr(10);

use constant SERVER_PORT => 40411;


my $sock = IO::Socket::INET->new(PeerHost => 'localhost', PeerPort => SERVER_PORT, Proto => 'tcp');

if($sock->connected)
{
  print "KARAMBA\n";

  my $request = "";
  my $response = "";
  while(lc($request) ne "quit" and lc($response) ne "quit")
  {      
     print "Eingabe: "\n";
     $request = <STDIN>;
     chomp $request;

     $sock->write("$request$CRLF", length($request)+2);
     print "YOU wrote: [$request]\n";
     $response = $sock->getline();
     chomp $response;
     $response =~ s!$CRLF$!!g; # to be sure
     print "SERVER wrote: [$response]\n";
  }
}
\n\n

<!--EDIT|esskar|1090317376-->

View full thread Socket Connect mit Perl: Socket Connect mit Perl