How can i handling bidirectional connections over TCP/UDP sockets?
Hi i play with the Generic protocol over TCP/UDP sockets.
I have the problem that i can not handle bidirectional data streams over TCP/UDP sockes using this setting: --generic=socket,out,10,localhost,65432,tcp,test (fg as the client to a server)
How can i do bidirectional data streams over one tcp/udp port that do the in/out trick.:
--generic=socket,out,10,localhost,65432,tcp,test
--generic=socket,in,10,localhost,65433,tcp,test
Or like to see a option that flight gear force as a server or client for handling bidirectional data streams.
www2
P.S. The code that i use for testing this:
test.py
- Code: Select all
#!/usr/bin/env python3
from time import time
import socket
HOST = '127.0.0.1' # Standard loopback interface address (localhost)
PORT = 65432 # Port to listen on (non-privileged ports are > 1023)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
print(data.decode('ascii').strip())
t = time()
conn.send(b"%i\n"%5000)
text.xml:
- Code: Select all
<?xml version="1.0"?>
<PropertyList>
<generic>
<output>
<line_separator>newline</line_separator>
<var_separator>tab</var_separator>
<chunk>
<name>altitude-ft</name>
<type>float</type>
<format>%f</format>
<node>/position/altitude-ft</node>
</chunk>
<chunk>
<name>airspeed-kt</name>
<type>float</type>
<format>%f</format>
<node>/velocities/airspeed-kt</node>
</chunk>
</output>
<input>
<chunk>
<name>test time</name>
<type>float</type>
<node>/position/altitude-ft</node>
</chunk>
</input>
</generic>
</PropertyList>