Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Information transfer over the internet
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$client\n";
}
sub ttt_disconnected {
my $self=shift;
my $client=shift;
print "disconnect:\t$client\n";
}
sub ttt_message {
my $self=shift;
my $client=shift;
my $message=shift;
print "(mess ",$cnt++,")\n";
print "$message\n";
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);



Report this thread to moderator Post Follow-up to this message
Old Post
Jonas Nilsson
04-07-05 08:56 AM


Re: Information transfer over the internet
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 mcse.ms - Unlimited-Uncensored-Secure Usenet News==-
---
http://www.mcse.ms The #1 Newsgroup Service in the World! >100,000 New
sgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---

Report this thread to moderator Post Follow-up to this message
Old Post
Bob Walton
04-07-05 08:56 AM


Re: Information transfer over the internet

Jonas Nilsson wrote:
 
>
> comp.lang.perl.misc:
> 
>
>
>
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:d2gcsv$iul$1@mamenchi.zrz.TU-Berlin.DE...
> 
>
>
> 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.


Report this thread to moderator Post Follow-up to this message
Old Post
Brian McCauley
04-07-05 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:57 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.