1

I've to set network name for the broadcast IP address for identify the device from another devices.

This is the code in python that successfully sets network name.

soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
soc.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
soc.sendto('connect-to-this-device'.encode(), (172.20.10.10, 1314))

I need same solution in Swift. I am aware of getting local ip address by using this solution. But I don't have any idea How to set broadcast message. I can use Objective-C or C solutions too. Please help me to find out. Thank you!

user2864740
  • 57,407
  • 13
  • 129
  • 202
Vin
  • 57
  • 5
  • Nothing in the code “sets a network name”; or rather, any listening device/processing is largely secondary to the core task now summarized in the title. – user2864740 Oct 24 '21 at 03:16
  • There is also nothing in the included code related to obtaining the network name (the shown code assumes a constant value). If this is a different task / issue / question, it should be in a different SO post. – user2864740 Oct 24 '21 at 03:18
  • @user2864740, Thank you for editing the title. Yes send a network broadcast message is correct. Yeah It's not about listening/obtaining process. I just want to send broadcast message. – Vin Oct 24 '21 at 03:40

0 Answers0