[Zope] python sockets on Suse 8.0

horst wald horstwald_@hotmail.com
Mon, 01 Jul 2002 16:03:27 +0000


Hi,

I'm running python 2.5.0 on Suse 8.0 and I'm trying to use sockets. I found 
the example programs "sockserver.py" and "sockclient.py" (see below) in a 
book but there are bugs in them. I fixed one in sockclient.py (it has to be 
"s.connect((HOST,PORT))", two parantheses) but I can't get sockserver.py to 
run. I keep getting

socket.error: (22, 'Invalid argument')

and this error occurs while processing the line

conn, addr = s.accept()

Any idea?
Might it be that the python sockets only work under UNIX and not LINUX?

Thanks in advance

Horst

----------------------------------------------------


file: sockserver.py

# Echo server program
from socket import *
HOST = ''                     # the local host
PORT = 50007                  # non-privileged server

s = socket(AF_INET, SOCK_STREAM)
s.bind(HOST, PORT)
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr

while 1:
    data = conn.recv(1024)
    if not data: break
    conn.send(data)
conn.close()


----------------------------------------------------


file: sockclient.py

# Echo client program
from socket import *
HOST = 'daring.cwi.nl'          # the remote host
PORT = 50007                    # the port used by server

s = socket(AF_INET, SOCK_STREAM)
s.connect(HOST, PORT)
s.send('Hello, world')

data = s.recv(1024)
s.close()
print 'Received', `data`


----------------------------------------------------

No more files...

_________________________________________________________________
Testen Sie MSN Messenger für Ihren Online-Chat mit Freunden: 
http://messenger.msn.de