Hi,
I am using a UDP socket and I am getting the ASCII data from the remote connection and I am able to send the data back to the UDP device that sent the message.
However, it only seems to work locally.
I have been told that I should be able to grab the Remote EndPoint, from the socket I receive data on, save it, then use it as the remote endpoint to send your reply back to without having to worry about opening ports in the customers router.
Been told the following is how it's done in .Net but not sure how to do it in B4J..
initiate an asynchronous “BeginReceive”:
When UDP data arrives, the callback, HandleXepUdpReceive is called and it performs an “EndReceive”:
the parameter UdpRemoteIpEndPoint is defined as:
IPEndPoint is a class in .net. That parameter, the remote endpoint is kept until I reply. It is simply the remote IP address and port that sent the data to me. I stuff the endpoint into a struct:
(That struct also contains the data to be sent in other members. I’m just showing you the remote endpoint (EP) member above)
And I call my UDB Send function (RmtUdpClient is my local endpoint – my local IP address and port):
When it goes out of a home’s router to the Internet, the router “remembers” it for several minutes so that when the reply comes back, the router automatically forwards it to the device on the network.
Anyone know how to do this in B4J ?
I am using a UDP socket and I am getting the ASCII data from the remote connection and I am able to send the data back to the UDP device that sent the message.
However, it only seems to work locally.
I have been told that I should be able to grab the Remote EndPoint, from the socket I receive data on, save it, then use it as the remote endpoint to send your reply back to without having to worry about opening ports in the customers router.
Been told the following is how it's done in .Net but not sure how to do it in B4J..
initiate an asynchronous “BeginReceive”:
B4X:
result = XepUdpClient.BeginReceive(NewAsyncCallback(AddressOfHandleXepUdpReceive),Nothing)
When UDP data arrives, the callback, HandleXepUdpReceive is called and it performs an “EndReceive”:
B4X:
receiveBytes = XepUdpClient.EndReceive(null, UdpRemoteIpEndPoint)
the parameter UdpRemoteIpEndPoint is defined as:
B4X:
DimUdpRemoteIpEndPointAsIPEndPoint=Nothing
IPEndPoint is a class in .net. That parameter, the remote endpoint is kept until I reply. It is simply the remote IP address and port that sent the data to me. I stuff the endpoint into a struct:
B4X:
XepSendData.EP = UdpRemoteIpEndPoint
(That struct also contains the data to be sent in other members. I’m just showing you the remote endpoint (EP) member above)
And I call my UDB Send function (RmtUdpClient is my local endpoint – my local IP address and port):
B4X:
DimlXepUdpClientAsUdpClient= XepSendData.RmtUdpClient
lXepUdpClient.Send(XepSendData.IOBuff, XepSendData.NumBytesInBuff, XepSendData.EP)
When it goes out of a home’s router to the Internet, the router “remembers” it for several minutes so that when the reply comes back, the router automatically forwards it to the device on the network.
Anyone know how to do this in B4J ?