perl socket filehandles 
Author Message
 perl socket filehandles

I'm trying to write a program that will get started from
inetd.  All I want to do is a getpeername on file descriptor
zero.  How do I assign in perl a particular value to a socket
filehandle so I can do things like getpeername?  I tried
doing simply  
        $mysockaddr = getpeername(0);
which gives me zip.

Sockets are not really my thing so I could be missing something
fundamentally trivial.  It seems that if I wanted to do a
getsockname I would have the same problem.  In this
particular case I don't care much about my end.  Anyone
have such a program I could use as an example?  

Barbara J.{*filter*}r                       Department of Computer Science
Computer Systems Manager               Campus Box 430B, ECEE00-69

(303) 492-2545                         Boulder, CO  80309-0430



Sat, 18 Feb 1995 02:15:15 GMT  
 perl socket filehandles

Quote:

>I'm trying to write a program that will get started from
>inetd.  All I want to do is a getpeername on file descriptor
>zero.  How do I assign in perl a particular value to a socket
>filehandle so I can do things like getpeername?  I tried
>doing simply  
>    $mysockaddr = getpeername(0);
>which gives me zip.

>Sockets are not really my thing so I could be missing something
>fundamentally trivial.  It seems that if I wanted to do a
>getsockname I would have the same problem.  In this
>particular case I don't care much about my end.  Anyone
>have such a program I could use as an example?  

I tried to reply by e-mail but something went wrong, so anyway...

The socket handling stuff from perl has been rewritten to use perl
filehandles instead of file descriptors -- you are NOT directly
calling the C library. So what you want is

        $mysockaddr = getpeername(STDIN);

and it will work as expected.

--
Greg Rose                 Australian Computing and Communications Institute



Sat, 18 Feb 1995 06:41:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sockets, filehandles, and weird behaviour

2. HOW TO: return a socket filehandle from sub?

3. A question about socket filehandles (how to close)

4. Sending filehandle to a client before closing socket

5. Can't print to filehandle while using IO::Socket

6. socket: read on close filehandle ???

7. Sockets and FileHandles

8. Filehandle [socket] refs

9. Can I create a filehandle from socket descriptor?

10. can i pass a filehandle through a socket?

11. Pass a socket filehandle to a child proc?

12. Q: Read from SOCKET filehandles

 

 
Powered by phpBB® Forum Software