Seite 1 von 1

Mehrere Netzwerkschnittstellen ansprechen

Verfasst: Freitag 8. Januar 2010, 14:14
von MrNiceTry
Wie kann man mehrere Netzwerkschnittstellen (eth0, eth1, ...) unter Python unterscheiden, bzw. ansprechen.

Wie geht das, wenn BaseHTTPServer verwendet wird?
Wie geht das mit Socket?

Verfasst: Freitag 8. Januar 2010, 14:19
von nemomuk

Code: Alles auswählen

In [4]: help(socket.socket.bind)
bind(self, *args) unbound socket._socketobject method
    bind(address)
    
    Bind the socket to a local address.  For IP sockets, the address is a
    pair (host, port); the host must refer to the local host. For raw packet
    sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])
Soweit ich weiß, kann man alle interfaces einfach mit None oder "" ansprechen.

Verfasst: Samstag 9. Januar 2010, 11:53
von MrNiceTry
SchneiderWeisse hat geschrieben:

Code: Alles auswählen

In [4]: help(socket.socket.bind)
bind(self, *args) unbound socket._socketobject method
    bind(address)
    
    Bind the socket to a local address.  For IP sockets, the address is a
    pair (host, port); the host must refer to the local host. For raw packet
    sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])
Soweit ich weiß, kann man alle interfaces einfach mit None oder "" ansprechen.
Sorry, das versteh ich so nicht. (mangels meiner Erfahrung).
Ist für mich zu theoretisch.
Wäre ein Stückchen Code, event. mit eth0/eth1 möglich.


Danke.

Verfasst: Samstag 9. Januar 2010, 14:47
von nemomuk
Schau einfach mal in der Dokumentation von socket, da sollten auch Beispiel vorhanden sein.

Verfasst: Samstag 9. Januar 2010, 15:53
von HWK
Suchst Du so etwas?
MfG
HWK