Socket error problem
David LeBlanc
whisper at oz.net
Sun Jun 9 16:45:19 EDT 2002
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Martin v. Loewis
> Sent: Sunday, June 09, 2002 13:17
> To: python-list at python.org
> Subject: Re: Socket error problem
>
>
> "David LeBlanc" <whisper at oz.net> writes:
>
> > The general.* constant references are to colorize the output
> which is turned
> > off but still results in the "31" in the connection error line in the
> > program output below. NOTE: I didn't write this code, so I have
> no idea why
> > it's returning the username in the socket.error instead of the
> host. FWIW,
> > this code is running in a thread, but there is only one thread
> trying to get
> > mail.
>
> That deserves some investigation since this, again, sounds impossible
> (how can it possibly know what the user name as, when this piece of is
> not being passed the user name). The only possible explanation is that
> self.error_msg prints unrelated information; I recommend to remove all
> except clauses and let the exception pass through.
>
> > self.sock = socket.socket(af, socktype, proto)
>
> Please put a print statement before this socket call, to print all
> three arguments.
>
> > self.sock.connect(sa)
> > except socket.error, msg:
>
> And put one here, printing socket.error.
>
> Regards,
> Martin
> --
> http://mail.python.org/mailman/listinfo/python-list
It knows the username because it got it out of a config file and supplied it
to the initializtion of POP3Server, which is what "serv" is.
I've put print statements around all this before I first tryed the ml, but
here they are again:
def __init__(self, host, port = POP3_PORT):
self.host = host
self.port = port
msg = "getaddrinfo returns an empty list"
self.sock = None
print 'poplib._init__: self.host = %s ' % self.host, 'self.port =
%s' % self.port
for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
self.sock = socket.socket(af, socktype, proto)
self.sock.connect(sa)
except socket.error, msg:
print 'poplib.__init__ socket.error msg = %s' % msg
if self.sock:
self.sock.close()
self.sock = None
continue
break
if not self.sock:
raise socket.error, msg
self.file = self.sock.makefile('rb')
self._debugging = 0
self.welcome = self._getresp()
And the output is:
K:\tmp\animail>animail -v
Opening Config file: c:/user/dave/.animail/animailrc
Trying to connect (mail.oz.net)
poplib._init__: self.host = mail.oz.net self.port = 110
poplib.__init__ socket.error msg = (10022, 'Invalid argument')
("Connection error (whisper): (10022, 'Invalid argument')", 31)
David LeBlanc
Seattle, WA USA
More information about the Python-list
mailing list