listening socket

cerr ron.eggler at gmail.com
Wed Sep 8 12:59:18 EDT 2010


Hi,

I'm trying to create a listening socket connection on port 1514.
I tried to follow the documentation at:
http://docs.python.org/release/2.5.2/lib/socket-example.html
and came up with following lines:
import socket

host = ''                 # Symbolic name meaning all available
interfaces
port = 1514               # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.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()
but that is not working, i'm getting this:
import: unable to open X server `' @ error/import.c/ImportImageCommand/
362.
./sockettest.py: line 4: host: command not found
./sockettest.py: line 5: port: command not found
./sockettest.py: line 6: syntax error near unexpected token `('
./sockettest.py: line 6: `s = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)'

now why would it try to open an x server??? :o



More information about the Python-list mailing list