Please help with Client / Server Blues.
Sindh
skodela at my-deja.com
Wed Aug 2 14:05:03 EDT 2000
Hi folks
I am trying to create a socket connection between two linux boxen.
server is as below. Then when I try to connect to the socket from other
machine which is connected via ethernet , [ which is up], it says
connection
refused.
But if I try to run both cli and server on the same machine with
127.0.0.1
if works without any problem.
my way of connecting is
from socket import *
s=socket(AF_INET,SOCK_STREAM)
s.connect("192.168.122.2",50000)
error message given is
Traceback (innermost last):
File "<stdin>", line 1, in ?
socket.error: (111, 'Connection refused')
can you locate where I'm doing wrong.
Thanks
sreekant
#################################
#server
################
#! /usr/bin/env python
from socket import *
import os
#get port and host
ipnum=gethostbyname("localhost")
portnum=50000
#create socket and listen
s=socket(AF_INET,SOCK_STREAM)
s.bind("localhost",portnum)
s.listen(8)
#start recieving
while 1:
conn,addr=s.accept()
data=conn.recv(1024)
if data=="READY":
conn.send("READY")
if data=="QUIT":
del s
raise SystemExit
if data!="READY" and data!="QUIT":
print data
try:
os.system(data) # try to execute to command
except:
pass
conn.close()
--
A man needs to sleep for 36 hours a day atleast.
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list