Android Question UDP Send and Receive different ports?

techknight

Well-Known Member
Licensed User
Longtime User
I need to be able to send on 1 port, and receive on a different port (to avoid collisions), How can I do that? I tried searching for an example and came up empty.

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
use two connections....
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Send is on one, Receive is on the other. Not sure how to handle the UDP Packet Received event for the connection I want. ?Because if data comes through on the send-only connection, I need to reject it.

Thats where I am at right now.
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Each socket has an event name, that you set when you initialize it.

B4X:
Sub Process_Globals
   Dim socketSend, socketReceive as UDPSocket
End Sub

Sub Activity_Create ...
   '...
   socketSend.initialize("socketSend",...)  'First parameter is the event name!
   socketReceive.initialize("socketReceive",....)
   '...
End Sub

Sub  socketReceive_PacketArrived (Packet As UDPPacket)
   '...this is he one that you are listening to  
End Sub
 
Upvote 0
Top