Question : How can I get X-Plane to recognize my UDP packets?

I'm working on a small VB.NET program to interact with X-Plane using the UDP interface, but X-Plane won't respond to the UDP packets I send to it.  I can successfully read and translate the UDP packets from X-Plane, but sending packets back to X-Plane seems to be a problem.  I don't receive any error messages, but X-Plane just doesn't respond -- very hard to debug.  I've included a simplified version of my transmission routine below.  The first part of the code shows the way I successfully capture packets from X-Plane.  The bytes in tgtmsg were captured from X-Plane while the ailerons were deflected a lot and X-Plane was only sending out the joystick position over UDP.  The second part of the code is what I thought would work to send a UDP command back to X-Plane, but X-Plane does not respond.

Instructions on how to accomplish this task in VB6 are here:
http://www.jefflewis.net/XPlaneUDP_9.html

I am using X-Plane 9.60rc2 demo and I'm running VB.NET Express 2008 9.0.30729.1 SP with .NET Framework 3.5 SP1 on Windows Vista 64-bit
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Dim srcmsg As Byte()
Dim tgtmsg As Byte() = {68, 65, 84, 65, 52, 8, 0, 0, 0, 124, 68, 170, 59, 124, 68, 170, 62, 202, 54, 136, 61, 0, 192, 121, 196, 0, 192, 121, 196, 0, 192, 121, 196, 0, 192, 121, 196, 0, 192, 121, 196}
Dim eprx As New IPEndPoint(IPAddress.Parse("127.0.0.1"), 49001)
Dim eptx As New IPEndPoint(IPAddress.Parse("127.0.0.1"), 49000)
Dim clienttx As New UdpClient(AddressFamily.InterNetwork)
Dim clientrx As New UdpClient(AddressFamily.InterNetwork)

clientrx.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1)
clientrx.Client.Bind(eprx)
srcmsg = clientrx.Receive(eprx)
'This is where I got the values for tgtmsg from srcmsg

clienttx.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1)
clienttx.Client.Bind(eptx)
clienttx.Send(tgtmsg, tgtmsg.Length, eptx)
clienttx.Close()

Answer : How can I get X-Plane to recognize my UDP packets?

Brute force trial and error prevails :)  The trick is that the tx client must be bound to a different port than the target port -- see code change below for the tx (second) section.
1:
2:
3:
4:
clienttx.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1)
clienttx.Client.Bind(New IPEndPoint(eptx.Address, 49003))
clienttx.Send(tgtmsg, tgtmsg.Length, New IPEndPoint(eptx.Address, 49000))
clienttx.Close()
Random Solutions  
 
programming4us programming4us