Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Catastrophic failure Unexpected method call sequence. 0x8000ffff (-2147418113)., ksh lock a file, [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_DBC failed, sed: -e expression #1, char 1: unterminated address regex, procmail + change subject, w2ksp4.exe download, /proc/kallsyms format, sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm

Links

XODOX
Impressum

#1: question about socket and scalar.

Posted on 2007-06-02 23:27:10 by none

Hammol,
I see an example about IPv6...
I'm a newby and I like to ask you someting about code:

-What can I put in the code(see following code) for writing what the
server says?
-What "scalar(@res)" do?

Thank you in advance,
Mario.


use Socket;
use Socket6;

@res = getaddrinfo('hishost.com', 'daytime', AF_UNSPEC, SOCK_STREAM);
$family = -1;
while (scalar(@res) >= 5) {
($family, $socktype, $proto, $saddr, $canonname, @res) = @res;

($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
print STDERR "Trying to connect to $host port port $port...\n";

socket(Socket_Handle, $family, $socktype, $proto) || next;
connect(Socket_Handle, $saddr) && last;

-----> WHAT CAN I PUT HERE TO PRINT WHAT SERVER SAYS?

close(Socket_Handle);
$family = -1;
}

if ($family != -1) {
print STDERR "connected to $host port port $port\n";
} else {
die "connect attempt failed\n";
}

Report this message

#2: Re: question about socket and scalar.

Posted on 2007-06-03 00:18:28 by Bob Walton

_mario.lat wrote:
> ...
> I'm a newby and I like to ask you someting about code:
>
....
> -What "scalar(@res)" do?

The function scalar() returns its argument evaluated in scalar context.
In the case of an array as the argument, it returns the number of
elements in the array.

Please type:

perldoc -f scalar

at a command prompt on your computer, which will answer this question
much more quickly and thoroughly than asking a newsgroup.
>
> Mario.
....
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl

Report this message

#3: Re: question about socket and scalar.

Posted on 2007-06-03 00:18:28 by Bob Walton

_mario.lat wrote:
> ...
> I'm a newby and I like to ask you someting about code:
>
....
> -What "scalar(@res)" do?

The function scalar() returns its argument evaluated in scalar context.
In the case of an array as the argument, it returns the number of
elements in the array.

Please type:

perldoc -f scalar

at a command prompt on your computer, which will answer this question
much more quickly and thoroughly than asking a newsgroup.
>
> Mario.
....
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl

Report this message

#4: Re: question about socket and scalar.

Posted on 2007-06-04 18:27:24 by Jim Gibson

In article <pan.2007.06.02.21.27.10.539855@libero.it>, _mario.lat
<none@libero.it> wrote:

> Hammol,
> I see an example about IPv6...
> I'm a newby and I like to ask you someting about code:
>
> -What can I put in the code(see following code) for writing what the
> server says?
> -What "scalar(@res)" do?
>
> Thank you in advance,
> Mario.
>
>
> use Socket;
> use Socket6;
>
> @res = getaddrinfo('hishost.com', 'daytime', AF_UNSPEC, SOCK_STREAM);
> $family = -1;
> while (scalar(@res) >= 5) {
> ($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
>
> ($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
> print STDERR "Trying to connect to $host port port $port...\n";
>
> socket(Socket_Handle, $family, $socktype, $proto) || next;
> connect(Socket_Handle, $saddr) && last;
>
> -----> WHAT CAN I PUT HERE TO PRINT WHAT SERVER SAYS?

If what "server says" is text terminated by new-lines:

while( defined($line=<Socket_Handle>)) {
print $line;
}

See 'perldoc ipc' and search for 'Internet TCP Clients and Servers'

>
> close(Socket_Handle);
> $family = -1;
> }
>
> if ($family != -1) {
> print STDERR "connected to $host port port $port\n";
> } else {
> die "connect attempt failed\n";
> }

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Report this message

#5: Re: question about socket and scalar.

Posted on 2007-06-04 18:27:24 by Jim Gibson

In article <pan.2007.06.02.21.27.10.539855@libero.it>, _mario.lat
<none@libero.it> wrote:

> Hammol,
> I see an example about IPv6...
> I'm a newby and I like to ask you someting about code:
>
> -What can I put in the code(see following code) for writing what the
> server says?
> -What "scalar(@res)" do?
>
> Thank you in advance,
> Mario.
>
>
> use Socket;
> use Socket6;
>
> @res = getaddrinfo('hishost.com', 'daytime', AF_UNSPEC, SOCK_STREAM);
> $family = -1;
> while (scalar(@res) >= 5) {
> ($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
>
> ($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
> print STDERR "Trying to connect to $host port port $port...\n";
>
> socket(Socket_Handle, $family, $socktype, $proto) || next;
> connect(Socket_Handle, $saddr) && last;
>
> -----> WHAT CAN I PUT HERE TO PRINT WHAT SERVER SAYS?

If what "server says" is text terminated by new-lines:

while( defined($line=<Socket_Handle>)) {
print $line;
}

See 'perldoc ipc' and search for 'Internet TCP Clients and Servers'

>
> close(Socket_Handle);
> $family = -1;
> }
>
> if ($family != -1) {
> print STDERR "connected to $host port port $port\n";
> } else {
> die "connect attempt failed\n";
> }

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Report this message

#6: Re: question about socket and scalar.

Posted on 2007-06-05 01:26:16 by Jim Gibson

In article <040620070927246688%jgibson@mail.arc.nasa.gov>, Jim Gibson
<jgibson@mail.arc.nasa.gov> wrote:

> See 'perldoc ipc' and search for 'Internet TCP Clients and Servers'

Sorry, but that is 'perldoc perlipc'.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Report this message

#7: Re: question about socket and scalar.

Posted on 2007-06-05 01:26:16 by Jim Gibson

In article <040620070927246688%jgibson@mail.arc.nasa.gov>, Jim Gibson
<jgibson@mail.arc.nasa.gov> wrote:

> See 'perldoc ipc' and search for 'Internet TCP Clients and Servers'

Sorry, but that is 'perldoc perlipc'.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Report this message

#8: Re: question about socket and scalar.

Posted on 2007-06-05 10:00:08 by Joe Smith

_mario.lat wrote:

> socket(Socket_Handle, $family, $socktype, $proto) || next;
> connect(Socket_Handle, $saddr) && last;
>
> -----> WHAT CAN I PUT HERE TO PRINT WHAT SERVER SAYS?

It depends on whether the server is sending ordinary lines of text or
binary data. For binary, you'll need to worry about is the end-of-field,
end-of-record/packet and end-of-stream indicators, as well as the expected
maximum size of a packet.

-Joe

Report this message

#9: Re: question about socket and scalar.

Posted on 2007-06-05 10:00:08 by Joe Smith

_mario.lat wrote:

> socket(Socket_Handle, $family, $socktype, $proto) || next;
> connect(Socket_Handle, $saddr) && last;
>
> -----> WHAT CAN I PUT HERE TO PRINT WHAT SERVER SAYS?

It depends on whether the server is sending ordinary lines of text or
binary data. For binary, you'll need to worry about is the end-of-field,
end-of-record/packet and end-of-stream indicators, as well as the expected
maximum size of a packet.

-Joe

Report this message