socket

Hola,

qualcuno sa dirmi perch�:

#!/usr/bin/perl

use IO::Socket;
#use diagnostics;
my $host=$ARGV[0];
if(!$host){
    die"...host???\n";
}
$|=1;

$socket=IO::Socket::INET->new(PeerAddr =>$host, PeerPort=>80, 
Proto=>"TCP") || die"$!\n";
print $socket "GET / HTTP/1.0\r\n\r\n";
while(<$socket>){
    print"$_\n";
}
close($socket);


FUNZIONA (scrivi e leggo dal socket),mentre al contrario:

#!/usr/bin/perl

use Socket;
#use diagnostics;
my $host=$ARGV[0];
if(!$host){
    die"...host???\n";
}
$|=1;

socket(SO,PF_INET,SOCK_STREAM,getprotobyname('tcp')) || die"$!\n";

my $dest=sockaddr_in(80,inet_aton($host));
connect(SO,$dest) || die"$!\n";
print SO "GET / HTTP/1.0\r\n\r\n";
while(<SO>){
    print"$_\n";
}

NON FUNZIONA...
ovvero per qualche oscuro motivo la lettura dal socket (<SO>), blocca la 
scrittura sul socket (print SO).
Se invece non cerco di leggere dal socket (cio� non c'� <SO>) la 
scrittura va a buon fine.
(Il tutto controverificato con uno sniffer).



Qualcuna sa dirmi perch�???

    Grazie
   
    Walter

0
waltervalenti
1/30/2002 4:11:14 PM
perl.beginners 29388 articles. 4 followers. Follow

3 Replies
693 Views

Similar Articles

[PageSpeed] 27

> -----Original Message-----
> From: walter valenti [mailto:waltervalenti@yahoo.it]
> Sent: Wednesday, January 30, 2002 11:11 AM
> To: beginners@perl.org
> Subject: socket=20
>=20
>=20
> Hola,
>=20
> qualcuno sa dirmi perch=E8:

(Using translator.dictionary.com, I see that the question is why the =
first=20
example "work" but the second blocks on the read, because the GET isn't
being=20
transmitted to the server.)

>=20
> #!/usr/bin/perl
>=20
> use IO::Socket;
> #use diagnostics;
> my $host=3D$ARGV[0];
> if(!$host){
>     die"...host???\n";
> }
> $|=3D1;
>=20
> $socket=3DIO::Socket::INET->new(PeerAddr =3D>$host, PeerPort=3D>80,=20
> Proto=3D>"TCP") || die"$!\n";
> print $socket "GET / HTTP/1.0\r\n\r\n";
> while(<$socket>){
>     print"$_\n";
> }
> close($socket);
>=20
>=20
> FUNZIONA (scrivi e leggo dal socket),mentre al contrario:
>=20
> #!/usr/bin/perl
>=20
> use Socket;
> #use diagnostics;
> my $host=3D$ARGV[0];
> if(!$host){
>     die"...host???\n";
> }
> $|=3D1;

This line sets only current filehandle (STDOUT) to autoflush. It =
doesn't
affect your socket. The example with IO::Socket::INET works because
IO::Socket::new() calls autoflush(1) on the socket.

   perldoc -f select
   perldoc -m IO::Socket (look at sub new)

>=20
> socket(SO,PF_INET,SOCK_STREAM,getprotobyname('tcp')) || die"$!\n";
>=20
> my $dest=3Dsockaddr_in(80,inet_aton($host));
> connect(SO,$dest) || die"$!\n";

You need something like:

   use IO::Handle;
   SO->autoflush(1);

> print SO "GET / HTTP/1.0\r\n\r\n";
> while(<SO>){
>     print"$_\n";
> }
>=20
> NON FUNZIONA...
> ovvero per qualche oscuro motivo la lettura dal socket=20
> (<SO>), blocca la=20
> scrittura sul socket (print SO).
> Se invece non cerco di leggere dal socket (cio=E8 non c'=E8 <SO>) la=20
> scrittura va a buon fine.
> (Il tutto controverificato con uno sniffer).
0
Bob_Showalter
1/30/2002 4:43:20 PM
--------------040503050709020409080803
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit


Sorry, for the Italian, but for an error i send here mail mail insted of 
perl-it !!!!!

I'm tryied to use send(SO,"GET / HTTP/1.0\r\n\r\n",0) and it work.

Thanks

    Walter


Bob Showalter wrote:




>>-----Original Message-----
>>From: walter valenti [mailto:waltervalenti@yahoo.it]
>>Sent: Wednesday, January 30, 2002 11:11 AM
>>To: beginners@perl.org
>>Subject: socket 
>>
>>
>>Hola,
>>
>>qualcuno sa dirmi perch�:
>>
>
>(Using translator.dictionary.com, I see that the question is why the first 
>example "work" but the second blocks on the read, because the GET isn't
>being 
>transmitted to the server.)
>
>>#!/usr/bin/perl
>>
>>use IO::Socket;
>>#use diagnostics;
>>my $host=$ARGV[0];
>>if(!$host){
>>    die"...host???\n";
>>}
>>$|=1;
>>
>>$socket=IO::Socket::INET->new(PeerAddr =>$host, PeerPort=>80, 
>>Proto=>"TCP") || die"$!\n";
>>print $socket "GET / HTTP/1.0\r\n\r\n";
>>while(<$socket>){
>>    print"$_\n";
>>}
>>close($socket);
>>
>>
>>FUNZIONA (scrivi e leggo dal socket),mentre al contrario:
>>
>>#!/usr/bin/perl
>>
>>use Socket;
>>#use diagnostics;
>>my $host=$ARGV[0];
>>if(!$host){
>>    die"...host???\n";
>>}
>>$|=1;
>>
>
>This line sets only current filehandle (STDOUT) to autoflush. It doesn't
>affect your socket. The example with IO::Socket::INET works because
>IO::Socket::new() calls autoflush(1) on the socket.
>
>   perldoc -f select
>   perldoc -m IO::Socket (look at sub new)
>
>>socket(SO,PF_INET,SOCK_STREAM,getprotobyname('tcp')) || die"$!\n";
>>
>>my $dest=sockaddr_in(80,inet_aton($host));
>>connect(SO,$dest) || die"$!\n";
>>
>
>You need something like:
>
>   use IO::Handle;
>   SO->autoflush(1);
>
>>print SO "GET / HTTP/1.0\r\n\r\n";
>>while(<SO>){
>>    print"$_\n";
>>}
>>
>>NON FUNZIONA...
>>ovvero per qualche oscuro motivo la lettura dal socket 
>>(<SO>), blocca la 
>>scrittura sul socket (print SO).
>>Se invece non cerco di leggere dal socket (cio� non c'� <SO>) la 
>>scrittura va a buon fine.
>>(Il tutto controverificato con uno sniffer).
>>
>
   


--------------040503050709020409080803--

0
waltervalenti
1/30/2002 5:13:18 PM
Why not just use FTP (File Transfert Protocol) ?
See Net::FTP module

Jos=E9.

-----Original Message-----
From: awards [mailto:awards@wanadoo.fr]=20
Sent: Thursday, August 14, 2003 6:09 PM
To: beginners@perl.org
Subject: Socket


Hi,


I would like to know if it is possible to transfer files from one computer =
to another using socket and Perl(obviously). And which module should I look=
 at. Also is there any good site to teach socket??

Thank You.
Anthony



--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org



**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is co=
nfidential and/or protected by intellectual property rights and are intende=
d for the sole use of the recipient(s) named above.=20
Any use of the information contained herein (including, but not limited to,=
 total or partial reproduction, communication or distribution in any form) =
by other persons than the designated recipient(s) is prohibited.=20
If you have received this e-mail in error, please notify the sender either =
by telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our=
 website at http://www.proximus.be or refer to any Proximus agent.

0
Jose
8/14/2003 4:25:27 PM
Reply:

Similar Artilces:

Beginner of Beginner getting an error
Hi Guys, I have this script: #!/usr/bin/perl # track, find email addresses in emails, # writes them to /var/opt/ITrootmail/bad/ with a date # set up as a pipe for procmail or use with Pine $now = `date`; # find included email-like addresses while ($line = <STDIN>) { if ($line =~ /\b([\w_\-\.]+ at [\w_\-\.]+)\b/) { # exclude email addresses not needed (next) if ( $1 =~ /\d{8,}/ ); (next) if ( $1 =~ /postmaster/i ); (next) if ( $1 =~ /DAEMON/i ); ...

ext/Socket/Socket.xs
In Socket.xs do I take it that this if (strEQ(name, "MSG_CTRUNC")) #if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */ return MSG_CTRUNC; #else goto not_there; #endif should be MSG_CTRUNC? As in: #if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */ Secondly, Socket.pm EXPORTs MSG_URG, but there is no code to generate it in Socket.xs. Was this an oversight somewhere? Nicholas Clark On Sun, Jun 03, 2001 at 03:03:46PM +0100, Nicholas Clark wrote: > In Socket.xs do I take it that this > > if (strEQ(...

Socket to Socket example needed
Does anyone have any configuration examples of how to set up a socket to socket connection. I would appeciate any examples or help anyone can offer. Thanks. Rob McGinness Rutland Regional Medical Center 802-747-6526 rmcginness@rrmc.org I guess that you talk about one AIM module that drives two socket conections. If you try to build such module, you must create two protocol objects within the project. Each protocol object can control its own related objects (frame, port, open, close, etc.) > Does anyone have any configuration examples of how to set > up a socket to socke...

SOCKET
Hi all!!! Can any body help me with some information or docs about Sockets with Power Builder. I'm Working with PB 6.5, but if you have an example in PB 7 I can use it. Now I'm waiting for your help. :-) If you mean three-tier apps, pb has it's own communication objects (transport, connection). If you need something more than that you can use third-party libraries as OLE objects, because you can't work from pob directly with wsock32.dll. <CARRADINE> wrote in message news:1111D847FE7E5A290058E38C85256C75.0058E3D185256C75@webforums... > Hi all!...

Socket
Dear The Expert, Where can I find complete articles for implementing windows socket in ASP.NET? TIA Winan...

Socket
How to get the ipaddress of the client machine using Socket programing,i want to check which r the pc's r connected to the server using vb.net any example will be very helpfull for me thanks in advance PrasantHI think therefore i'mvPras© If you're representing the client as a Socket, this class has a RemoteEndPoint Public property that is of type EndPoint. It encapsulates information about the client. If you're representing the client as a TcpClient, this class has a Protected Client property of type Socket (thus getting to the RemoteEndPoint). Protected meaning you have ...

Sockets
Does anyone have a suggestion for the easiest and best way to implement sockets in their PB application? Thanks. Shenn Sellers waste.ssellers@co.riverside.ca.us I use freeware OCX (SocketWrench) from Catalyst (www.catalyst.com) Wether it is the best implementation I don't know, but it works for me. Maciek. Shenn Sellers wrote: >Does anyone have a suggestion for the easiest and best way to implement >sockets in their PB application? > >Thanks. > >Shenn Sellers >waste.ssellers@co.riverside.ca.us > > > ...

Sockets
Hi, Is it possible to make a sockets connection with PB6.5? (and how) Thanks in advance, Joe I think this is what you're looking for http://www.teamsybase.com/roy.kiesler/downloads/wininet.zip HTH Arnoud Url: http://www.gloriant.be <Joe> wrote in message news:7F08A3D1FC072C7E003E028585256CC2.003E029385256CC2@webforums... > Hi, > > Is it possible to make a sockets connection with PB6.5? (and how) > > > Thanks in advance, > Joe > WinInet cannot be used for raw socket connection -- it is a simple wrapper for FTP/HTTP/Gop...

Sockets
Is it possible to connect to Sybase ASE using Unix domain sockets instead of TCP/IP? Paul Ryland dpar2@cam.ac.uk Davin Yap wrote: > > Is it possible to connect to Sybase ASE using Unix domain sockets > instead of TCP/IP? Not that I know of. Michael -- Michael Peppler -||- Data Migrations Inc. mpeppler@peppler.org -||- http://www.mbay.net/~mpeppler Int. Sybase User Group -||- http://www.isug.com Sybase on Linux mailing list: ase-linux-list@isug.com This is a cryptographically signed message in MIME format. --------------msA85E21818DD8367FB19...

sockets
I'll be simple. I would like Java style Sockets, and Server Sockets. So I can write pb apps to connect/interface/serve directly to other apps based on TCP/IP. Without having to resort to going to third party controls. I would also like my EAServer course not to be posponed for another two months because noone apart from myself wants to go. I've been booked in since Nov last year, and still noone in Sydney wants to go. I've been told that they won't even consider a one-one training session, I think that says quite a lot about why there is a sheer lack of interest i...

socket.
------=_NextPart_000_06EB_01C3BF4D.037FCCC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have installed DBI-1.19, and trying to use radiator radius server to = call an MySQL query using DBI. I am getting the following error. My = actual socket is under /etc. I guess this error originates from the DBI. The install was perfect. Deen Wed Dec 10 18:29:47 2003: DEBUG: Handling request with Handler 'Realm=3DDEFAULT' Wed Dec 10 18:29:47 2003: DEBUG: Deleting session for mikem, 203.63.154.1, 1234 Wed Dec 10 ...

About sockets
May be this das not belong hire but I need to know. How can I determent that the packet was realy sent and received? How to disconect socket when there is no function for disconect? Milan, there is no way to see what is transmitted on the socket without doing hardward sniffing. as for closing the connection check out the property SocketReuseLimit. If you set that to 1 then it will close the connection after every call. -- Scott McReynolds Engineering Manager <Milan> wrote in message news:CCF158963E252705001EB0DD85256BEC.001EB0EA85256BEC@webforums... > May be th...

Sockets
PB8.0 W2K What do people use to implement sockets in PB? Nathan I just use the API functions. On Tue, 31 Dec 2002 11:02:34 -0600, NP <tarsi@no-see-evil.binhost.com> wrote: >PB8.0 >W2K > >What do people use to implement sockets in PB? > >Nathan Bruce Armstrong [TeamSybase] http://www.teamsybase.com Not 1 - but 2 new books on developing with PowerBuilder http://www.pb9books.com Which can now be pre-ordered through Amazon.com http://www.amazon.com/exec/obidos/tg/detail/-/0672325004 http://www.amazon.com/exec/obidos/tg/detail/-/0672324997...

Web resources about - socket - perl.beginners

AC power plugs and sockets - British and related types - Wikipedia, the free encyclopedia
Plugs and sockets for portable appliances originated in Britain in the 1880s and were initially two pin designs. These were usually sold as a ...

usb charger to fit a car lighter socket - Flickr - Photo Sharing!
Made a quick l7805 (think minty boost) charger for some gadgets. Runs from a car cigarette lighter plug, and outputs 5vdc to a female usb socket. ...

Mitch Robinson lied to Carlton about incident that left him with a broken eye socket
Mitch Robinson lied to Carlton officials when asked why he had suffered a broken eye socket during a scuffle in the early hours of Sunday morning. ...

Brisbane Broncos forward Alex Glenn facing six weeks on sideline with fractured eye socket
Wayne Bennett ranks Brisbane fullbacks as Justin Hodges injury leaves Broncos with fifth choice rookie

ASRock Rack Announces EP2C612D24 and 4L: Dual Socket Haswell-EP with 24 DDR4 Slots
... 16GB UDIMMs, this allows for a maximum of 384GB, although moving up to RDIMM, LRDIMMs or 64GB NVDIMMs pushes the max to 1.5TB in a dual socket ...

Meet Beam, the Android projector that turns any light bulb socket into an entertainment center
In case you were looking for an out-of-the-box smart projector, then Beam might be worth looking into. The unusual-looking device has just been ...

A charred eye socket provides proof that 43 missing Mexico students are dead
People gather outside of the home of Alexander Mora, one of 43 college students missing since September whose charred remains have now been positively ...

Cool Chart of the Week: Solar Socket Parity In California, Australia, Germany, Italy, & Netherlands
I forget now how I ran across this chart, but it’s a nice one. It shows that residential solar PV power hit socket parity (aka grid parity) in ...

Dell Aims Four-Socket Server at Modern Database Hardware Needs
... out a greater percentage of the high-end server market, such as in-memory database hardware requirements, Dell today unveiled a four-socket ...

Video: Socket To Me! Nitwit At ‘Hand To God’ Tries To Charge Phone On Set
... on a performance of Hand To God at Broadway ’s Booth Theatre a few days ago, this patron leapt onstage and tried to plug his phone into a socket ...

Resources last updated: 11/22/2015 1:23:58 PM