Server code:
import os, sys, socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = ''
port = 5602
s.bind((host,port))
try:
s.listen(1)
while 1:
conn, addr = s.accept()
print 'client is at', addr
data = conn.recv(1000000)
data = data * 10
z = raw_input()
conn.send(data)
conn.close()
except Exception:
s.close()
Client code:
import sys, os, socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = 'hostIP'
port = 5602
s.connect((host,port))
s.send(dlg.user.GetValue())
i =0
while True:
data = s.recv(1000000)
i+=1
if (i<5):
print data
if not data:
break
print 'received', len(data), 'bytes'
s.close()
David Harrison wrote:
On 18/04/2008, Astan Chee <[EMAIL PROTECTED]> wrote:
Hi,
I have a client-server socket script in python. Something like this
http://ubuntuforums.org/showthread.php?t=208962
Now the problem I have is that I want to try to connect the client to
the server on the same machine, but it gives me a 'port already in use'
error. I just want the client to connect to the server for testing
purposes. Any suggestions on how I should do this?
Thanks
Astan
Can you post the client / server code for us ? It sounds like it's
likely to be a minor bug.
--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two."
Animal Logic
http://www.animallogic.com
Please think of the environment before printing this email.
This email and any attachments may be confidential and/or privileged. If you
are not the intended recipient of this email, you must not disclose or use the
information contained in it. Please notify the sender immediately and delete
this document if you have received it in error. We do not guarantee this email
is error or virus free.
--
http://mail.python.org/mailman/listinfo/python-list