In my app I am connecting to a device that has it\'s own WiFi network. In android 6 and above the system asks me after a few seconds if I want to connect to this network eve
For those still attempting to figure this out, based on the
wifiNetwork.bindSocket(socket)
provided by @MayconPrado
Yes, that socket variable was declared ahead of time. That answer assumes you are sending UDP or TCP packets over the network.
The partial but more complete code would look something along the lines of
val socket = DatagramSocket(somePortNumber)
wifiNetwork.bindSocket(socket)
val udpPacket = DatagramPacket(/** args specific to use case **/)
socket.send(udpPacket)
Would have commented this, but I have never posted to SO, so I have 1 rep ATM.