Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] python socket.connect() issue



Hi,

I am trying to use python's socket.connect() to establish a TCP connection from
host A (192.168.4.1) to host B (192.168.4.2). (In B I have a TCP socket in port
33622 listening)
The script running in A is something like this:

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
remote_ip = '192.168.4.2'
remote_port = 33622
client.connect ((remote_ip, remote_port))

When running the program in A, I noted that, instead of trying to connect
directly using the provided IP address (192.168.4.2), it looks for a DNS server
(as specified in /etc/resolv.conf I guess). Since I don't have the DNS server
available during the execution of this script, connect() times out
with the following error:
socket.gaierror: (-2, 'Name or service not known')

The question is: why connect() looks for the DNS server instead of using the
specified IP address?

Thanks,
Hector


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links