Frage

I have two computers (and nothing else) plugged directly into a network switch, and I am trying to get one to connect to the other via twisted.internet.reactor.connectTCP(addr, 8000, factory). What should I have as addr?

On the computer I'm trying to connect to (hand-copied, so there could be typos):

$ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:92:e3:cc
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:126 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:41328 (40.3 KiB)  TX bytes:3850 (3.7 KiB)

[snip]

Thanks for any help!

War es hilfreich?

Lösung

This question is not really about Twisted, but about networking. Twisted's connectTCP connects from some IP address on your computer to some IP address on a remote computer. You don't need to specify the source address usually because your local TCP stack will automatically discover the correct one to use based on the remote one. However, both computers need to have IP addresses that can route to each other.

The output you're showing from ifconfig is showing that you have an ethernet device, but that device does not have an associated IP address. There's no IP address for you to give to Twisted because your network is not set up fully enough for connectTCP (or other software that operates even at the IP layer, let alone at the higher level that connectTCP is at, which is TCP) to work.

You need to somehow assign an IP address to that interface on both the local and the remote device, if they're just plugged directly into a network switch with no DHCP server (or some other mechanism like SLAAC) to give them an address directly. You also need to set up your netmask and everything else so that the two computers can route to each other.

I'm not going to tell you how to do that in this answer because it depends heavily upon your network configuration and operating system. However, that would be a good candidate for something on Super User as Jean-Paul put it in his comment.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top