Changeset 108:7b985f3a0ee1 in xplra
- Timestamp:
- 12/15/22 19:27:40 (2 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/python/xplra.py
r103 r108 121 121 ## Hotkey modifier: Control 122 122 HOTKEY_MODIFIER_CONTROL = 0x0200 123 124 #------------------------------------------------------------------------------- 125 126 ## The default TCP port ("XR") 127 DEFAULT_TCP_PORT = 0x5852; 123 128 124 129 #------------------------------------------------------------------------------- … … 296 301 self._multiBuffers = [] 297 302 298 def connect(self ):303 def connect(self, address = None): 299 304 """Try to connect to X-Plane.""" 300 305 if self._stream is not None: 301 306 return 302 307 303 if os.name=="nt": 304 pipe = Win32NamedPipe(r'\\.\pipe\\xplra') 305 self._stream = io.BufferedRWPair(pipe, pipe) 306 else: 307 import socket 308 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 309 s.connect("/tmp/xplra-" + os.environ["LOGNAME"]) 310 self._stream = s.makefile("rwb") 308 if address: 309 if address.startswith("tcp:"): 310 address = address[4:] 311 colonIndex = address.find(":") 312 if (colonIndex<=0): 313 port = DEFAULT_TCP_PORT 314 else: 315 port = int(address[colonIndex+1:]) 316 address = address[:colonIndex] 317 318 import socket 319 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 320 print("Connecting to TCP address '%s':%d" % 321 (address, port)) 322 s.connect((address, port)) 323 self._stream = s.makefile("rwb") 324 elif address!="local": 325 raise ValueError("Invalid address: " + address) 326 327 if self._stream is None: 328 if os.name=="nt": 329 pipe = Win32NamedPipe(r'\\.\pipe\\xplra') 330 self._stream = io.BufferedRWPair(pipe, pipe) 331 else: 332 import socket 333 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 334 s.connect("/tmp/xplra-" + os.environ["LOGNAME"]) 335 self._stream = s.makefile("rwb") 311 336 312 337 for multiBuffer in self._multiBuffers:
Note:
See TracChangeset
for help on using the changeset viewer.