swiftsocket / SwiftSocket

The easy way to use sockets on Apple platforms
BSD 3-Clause "New" or "Revised" License
1.68k stars 400 forks source link

How to get local binded port from UDPClient #187

Open anuranBarman opened 4 years ago

anuranBarman commented 4 years ago

Hi, I am trying to use this library in UDP communication with the server. I am able to send and receive data to and from the server but what I want to know is the local port it used to communicate with the server.

The reason I want to know the local port is that as that port is hole-punched in the router I want to use the same port for P2P connection with some embedded devices.

How can I get the local PORT ? and if Not possible how do I tell the library to bind to specific port which I define while creating the socket ?