Question: How to use sockets 
Author Message
 Question: How to use sockets

I tried some sample programs from the perl camel book but they don't work for
what I want to do.

For example, let's say I was writing a 'finger' client in perl.

I would want to connect to the server's finger port and submit a request to
the finger daemon and read the results, yet when I tried the example, I don't
think my client switched to the new port where the answer was to be sent back,
it stayed put on the initial port.

Would it be possible for someone to point me to a resource that shows how to
use Sockets for this type of example? Preferably something with non-blocking
calls or timeouts so you don't end up waiting forever in case a daemon doesn't
respond. A sample program would be even better. Any help that anyone can
provide would be greatly appreciated.

Thanks
Greg



Fri, 14 Jan 2000 03:00:00 GMT  
 Question: How to use sockets

Quote:

> I tried some sample programs from the perl camel book but they don't work for
> what I want to do.

> For example, let's say I was writing a 'finger' client in perl.

> I would want to connect to the server's finger port and submit a request to
> the finger daemon and read the results, yet when I tried the example, I don't
> think my client switched to the new port where the answer was to be sent back,
> it stayed put on the initial port.

> Would it be possible for someone to point me to a resource that shows how to
> use Sockets for this type of example? Preferably something with non-blocking
> calls or timeouts so you don't end up waiting forever in case a daemon doesn't
> respond. A sample program would be even better. Any help that anyone can
> provide would be greatly appreciated.

Net::Telnet provides a simple interface to client side TCP sockets.
It has an associated timeout for connecting, reading, and writing.
Also check-out IO::Socket.  It lets you specify a timeout on
connection.

You can find Net::Telnet on CPAN.

Here's a simple implementation of finger with a 20 second timeout


    use Net::Telnet ();
    $obj = new Net::Telnet (Timeout => 20);
    $obj->open(Host => 'localhost', Port => 79);

    $obj->print($user);
    while (! $obj->eof) {

    }


--
Jay Rogers



Fri, 14 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. using an array as a socket handler question

2. DBI and mysql using non-default socket question

3. Time out with perl Socket using IO::Socket

4. Help with creating UDP sockets using IO::Socket

5. Creating udp sockets using IO::Socket

6. mod_perl problems - core dump using Socket or IO:Socket in startup.pl

7. mod_perl problems - core dump using Socket or IO:Socket in startup.pl

8. Socket communication using IO::Socket (sending/receiving)

9. Please help w/using Socket.pm

10. I/O on Win32, using: IO::Socket::INET

11. Using IO::Socket to get a webpage

12. simple Socket client/server program with problems using sockaddr_in()

 

 
Powered by phpBB® Forum Software