Browse files

choose address family in OSCClient._ensureConnect

The address family is chosen based on the address tuple length - ipv6
addresses are normally represented as (host, port, flowinfo, scopeid)
tuple, so len(address) looks like a possible way to check if we're
dealing with ipv6.
  • Loading branch information...
1 parent 01d874f commit 633c0112318a3519314aa798a552a092566c73c1 @artfwo artfwo committed with Artem Baguinski Jun 28, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 OSC.py
View
7 OSC.py
@@ -1055,8 +1055,11 @@ def _setSocket(self, skt):
def _ensureConnected(self, address):
"""Make sure client has a socket connected to address"""
if not self.socket:
- # TODO chose the right address family based on addr or somesuch
- self._setSocket(socket.socket(socket.AF_INET, socket.SOCK_DGRAM))
+ if len(address) == 4:
+ address_family = socket.AF_INET6
+ else:
+ address_family = socket.AF_INET
+ self._setSocket(socket.socket(address_family, socket.SOCK_DGRAM))
self.socket.connect(address)
def setServer(self, server):

0 comments on commit 633c011

Please sign in to comment.