I try to establish a data exchange between Flightgear and a Python application through UDP sockets. Data transfer from Flightgear to the Python program is already working perfectly.
For data transfer from Python to Flightgear, I start FG using AP_I.xml as input protocol file with
- Code: Select all
fgfs --generic = socket, in, 10, localhost, 52867, udp, AP_I
In Python, I use the following class member code to establish a connection:
- Code: Select all
try:
self.Iface = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
print("Socket created.");
except socket.error as msg :
print('Failed to create socket. Error Code : ' + str(msg);
sys.exit();
try:
self.Iface.bind((self.Host, self.Port));
except socket.error as msg:
print('Bind failed. Error Code : ' + str(msg));
sys.exit();
print("Socket binding complete.");
Whenever I try to establish the connection, I get an error message on the call to Iface.bind():
"Bind failed. Error Code: [Error 98]: Address already in use."
I get this message whenever I try to open a socket on the FG "in" port, no matter, which port number I use.
I examined the port numbers with netstat, but this does not raise any conflicts. The port numbers are definitely not in use.
What am I doing wrong? And why does none of the many descriptions of the generic protocol, you can find in the internet, give an example for the "input" direction? It would be helpful to get a functional example of how to send data to Flightgear from external applications.
Thank you in advance.
Autowings