Click here to get back home

Information transfer over the internet

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Information transfer over the internet Jonas Nilsson 03-31-2005
Posted by Jonas Nilsson on March 31, 2005, 10:46 am
Please log in for more thread options


Hello
I would like to transfer some information between two computers with
internet connection. One computer should act as a server and the other as a
client. I really don't know much about sockets, ports or protocols.

I played around some with the code below but i reallt don't know what I am
doing. The module Net::Server::NonBlocking2 is the same as
Net::Server::NonBlocking, but I removed some error checking due to problems
with unimplemented perl funcions on my PC. This actually givs some
information to a browser when I type http://127.0.0.1:10000. This however
isn't working properly.I actually have to close the client to get any
response at all. There must be some modules that easily and nicely can do
something like the quasicode below.

Please assist me.
/jN

_CODE_
use Net::Server::NonBlocking2;
$|=1;

$obj=Net::Server::NonBlocking2->new({"pidfile" => "tmppid.pid"});
$obj->add({
server_name => 'tic tac toe',
local_port => 10000,
timeout => 60,
delimiter => "n",
on_connected => &ttt_connected,
on_disconnected => &ttt_disconnected,
on_recv_msg => &ttt_message,
});
our $cnt="000";
$obj->start;
sub ttt_connected {
my $self=shift;
my $client=shift;
print "connect:t$clientn";
}
sub ttt_disconnected {
my $self=shift;
my $client=shift;
print "disconnect:t$clientn";
}
sub ttt_message {
my $self=shift;
my $client=shift;
my $message=shift;
print "(mess ",$cnt++,")n";
print "$messagen";
print $client "dfgdg: message<BR>testmessage<BR>";
$client->close;
}

_QUASICODE_

server:
while (1) {
if (&new_message) {
my $input=&message;
my $output=&parse($input);
&send_message($output);
} else {
sleep(5);
}
}

client:
my $request="Give me checksum of C:/Tmp/test.txt";
my $answer=&send_request($request,"mycomp.mynet.com") or "Die no answer!";
&handle($answer);




Posted by Anno Siegel on March 31, 2005, 9:37 am
Please log in for more thread options


> Hello
> I would like to transfer some information between two computers with
> internet connection. One computer should act as a server and the other as a
> client. I really don't know much about sockets, ports or protocols.

A Perl newsgroup is not the first choice of a place to learn about them.

> I played around some with the code below but i reallt don't know what I am
> doing. The module Net::Server::NonBlocking2 is the same as
> Net::Server::NonBlocking, but I removed some error checking due to problems
> with unimplemented perl funcions on my PC.

Then the module (which I don't know) is probably not fit to run in
your environment. In a situation where you are not entirely sure
what you are doing, dropping error checks is a bad idea.

> This actually givs some
> information to a browser when I type http://127.0.0.1:10000.

So you want to write a web server. This is hard to do from scratch,
as you are trying to do. You should use a module that supports the
HTTP protocol. There is a group of modules HTTP::Server::... on
CPAN that look promising.

Anno


Posted by Jonas Nilsson on March 31, 2005, 11:59 am
Please log in for more thread options


comp.lang.perl.misc:
> > This actually givs some
> > information to a browser when I type http://127.0.0.1:10000.


> So you want to write a web server.

Actually no. I just try to do some learning by playing around... Not very
successfuly however, since the issue is a bit more complex than I realized.

Actually I need something very simple that can send strings/binaries over
the internet between a perl-client and a perl-server. Re-posting the
quasicode from the initial message might clear up my intentions:

_QUASICODE_

server:
while (1) {
if (&new_message) {
my $input=&message;
my $output=&parse($input);
&send_message($output);
} else {
sleep(5);
}
}

client:
my $request="Give me checksum of C:/Tmp/test.txt";
my $answer=&send_request($request,"mycomp.mynet.com") or "Die no answer!";
&handle($answer);





Posted by Brian McCauley on March 31, 2005, 5:53 pm
Please log in for more thread options




Jonas Nilsson wrote:

>
> comp.lang.perl.misc:
>
>>> This actually givs some
>>>information to a browser when I type http://127.0.0.1:10000.
>
>
>
>
>>So you want to write a web server.
>
>
> Actually no. I just try to do some learning by playing around... Not very
> successfuly however, since the issue is a bit more complex than I realized.
>
> Actually I need something very simple that can send strings/binaries over
> the internet between a perl-client and a perl-server. Re-posting the
> quasicode from the initial message might clear up my intentions:
>
> _QUASICODE_
>
> server:
> while (1) {
> if (&new_message) {
> my $input=&message;
> my $output=&parse($input);
> &send_message($output);
> } else {
> sleep(5);
> }
> }
>
> client:
> my $request="Give me checksum of C:/Tmp/test.txt";
> my $answer=&send_request($request,"mycomp.mynet.com") or "Die no answer!";
> &handle($answer);

I suggest you look at the section that deals with sockets in any Perl
tutorial.

In the standard Perl documentation there's some socket examples in perlipc.



Posted by Bob Walton on March 31, 2005, 10:00 pm
Please log in for more thread options


Jonas Nilsson wrote:

> Hello
> I would like to transfer some information between two computers with
> internet connection. One computer should act as a server and the other as a
> client. I really don't know much about sockets, ports or protocols.

Check out:

perldoc perlipc

at a command prompt, particulary the section titled "Internet TCP
Clients and Servers". There is example code there which should
get you on your way.

....

--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


Similar ThreadsPosted
Retrieving information from website July 28, 2006, 4:47 pm
Parsing AVI header information June 8, 2008, 11:08 pm
Adding XSLT information to XML generated by DBIx::XML_RDB July 20, 2008, 10:00 am
Net::SFTP transfer speed December 14, 2004, 8:14 am
Looking for a file transfer module NOT ftp May 9, 2006, 11:12 pm
A lib Net::FTP question.(Transfer file to OpenVMS) July 6, 2007, 1:46 am
Mail::Internet Debian Package January 9, 2005, 3:29 pm
Naming modules from the Internet Archive April 14, 2006, 10:24 pm
Starting a perl program when I connect to the internet. September 22, 2004, 3:34 pm
Loading (from Internet), resizing and saving images March 22, 2005, 6:15 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap