in reply to IO::Socket error in CGI on apache

There could be a number of reasons for this, most of which are outside the control of the Perl program. In the first instance you should print out the actual error message from the system in the case where the returned socket is undef. You could do something like:

if ( $pop3 ) { # do something with the socket } else { print "error in socket: $!"; }

If you are trying to create a POP3 client you might be better off using a pre-existing module such as Net::POP3 or Mail::POP3Client which will do all the work for you.

/J\

Replies are listed 'Best First'.
Re^2: IO::Socket error in CGI on apache
by Anonymous Monk on May 25, 2006 at 08:22 UTC
    I only take pop3 for example. Actually any protocol which are right in command line use can not work correctly in my apache cgi environment . Like this 80 port:

    #!/usr/bin/perl use strict; use warnings; use IO::Socket; my $http = IO::Socket::INET->new( PeerAddr => "mail.163.com", PeerPort => 80, Proto => 'tcp', Timeout => 20 ); print "Content-type: text/html\n\n"; print "Result: "; print $http;