[Tutor] View pop3 commands/responses script

Steve slyskawa@yahoo.com
Fri, 22 Mar 2002 16:03:51 -0500


I am a beta tester for an email program.  I have a program which 
emulates a server that I use to manually test it.  I want to create 
a python script that will allow me to see what the mail program is 
sending to the pop3 server and to see the responses back from the 
server to the mail program.

I started the script and it is able to accept a call from the mail 
program.  I used server.py by Joe Strout as an example.  I am 
having problems connecting to the remote pop3 server.  I have no 
problem doing this using the poplib, but I never tried it using the 
socket library.  I suspect my problem is that I cannot use the bind 
command for a remote server.  Here is my script:

from socket import *
import string,time
local=socket(AF_INET,SOCK_STREAM)
local.bind(('127.0.0.1',110))
local.setblocking(0)
local.listen(1)
addr=0
while not addr:
   try:
      conn,addr=local.accept()
   except:
       pass
print 'ip,port ',conn,addr
conn.setblocking(0)
remote=socket(AF_INET,SOCK_STREAM)
remote.bind(('192.108.102.201',110))
remote.setblocking(0)
remote.listen(1)

count = 0
while count < 10:
    time.sleep(1)
    count=count+1
    try:
        data = conn.recv(1024)
        print data
    except:
        pass

local.close()

Here is my error:
ip,port  <socket._socketobject instance at 007F7714> 
('127.0.0.1',4719)
Traceback (most recent call last):
  File "D:\apps\Python\sjl\EmailServer.py", line 16, in ?
    remote.bind(('192.108.102.201',110))
  File "<string>", line 1, in bind
socket.error: (10049, "Can't assign requested address")


When I get this working, I want data to flow back and forth to the 
server and I want to either log stuff to a file or print on the 
console.  Any help would be appreciated.
-- 
Steve



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com