Dolamite Jenkins
asked on
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it\par
Sockets Cant Connect Over Lan so reading the forum I need to get the host name
I've disable the firewall
1.this the server side code and addr = gethostbyname() iis causeing the error
2. do I have to get the the hostbyname on the client side too ?
3. Is there anything else Im missing
client side
Traceback (most recent call last):
File "c:\Python26\network folder\server_side_xxx.py", line 13, in <module>
addr = (gethostbyname(gethostname()), port)
NameError: name 'gethostbyname' is not defined
I've disable the firewall
1.this the server side code and addr = gethostbyname() iis causeing the error
2. do I have to get the the hostbyname on the client side too ?
3. Is there anything else Im missing
import socket
host = ''
port = 50000
backlog = 5
size = 1024
addr = (gethostname(), port)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((addr))
s.listen(backlog)
while 1:
client, address = s.accept()
data = client.recv(size)
if data:
client.send(data)
client.close()
client side
import sqlite3
import sqlite3 as lite
import socket
host = 'localhost'
port = 50000
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
f = open('ban.txt', "r")
data2 = f.read()
f.close()
s.connect((host,port))
s.send(data)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In case it wasn't completely clear, the second form of import allows you to drop the qualifier from references to any method in the socket library; the first form is specific only to the gethostname method.
ASKER
do I need to do that on the client side too ?
ASKER
im still getting the error on the client side
import sqlite3
import sqlite3 as lite
import socket
Traceback (most recent call last):
File "c:\Python26\network folder\client_side_xxx.py", line 22, in <module>
s.connect((host,port))
File "<string>", line 1, in connect
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it
Process terminated with an exit code of 1
import sqlite3
import sqlite3 as lite
import socket
host = 'localhost'
port = 50000
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
f = open('ban.txt', "r")
data2 = f.read()
f.close()
s.connect((host,port))
s.send(data)
ASKER
Thanks