</CODE>Consider this: <CODE> #!/usr/local/bin/perl use strict; use Socket; use FileHandle; my $port = 11111; socket(SOCKET, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]); bind (SOCKET, pack('Sna4x8', AF_INET, $port, "\0\0\0\0")); listen(SOCKET, 3); NEW_SOCKET->autoflush(); SOCKET->autoflush(); while (1) { accept(NEW_SOCKET, SOCKET); my $pid; if (! ($pid = fork)) { my $xxx = read_query(\*NEW_SOCKET); select(NEW_SOCKET); print "Port 11111 is available on my server\n"; print "Querystring is: <br>$xxx</br>\n"; close NEW_SOCKET; exit; } } sub read_query { my ($client_stream) = @_; my $whole_query = <$client_stream>; $whole_query =~ m{GET .*?\?(\S+)}; return $1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Extracting a Query string
by Anonymous Monk on May 21, 2000 at 22:29 UTC | |
by chromatic (Archbishop) on May 22, 2000 at 03:47 UTC |