ExistentialAudio/SwiftOSC

Cannot broadcast messages

0x0c opened this issue · 8 comments

0x0c commented

Hello, I use SwiftOSC to broadcast messages, but I cannot receive my computer.
The computer and my iPhone connects same wifi.
Sending messages to specific ip address is works.

Is there any workaround?

0x0c commented

The computer and the iPhone joined same network.
Its network address is 192.168.1.0, and my app runs on the iPhone send messages to 192.168.1.255 as known as broadcast address.
I think my computer receive messages, however no messages received.
Instead of broadcasting, send specific address like 192.168.1.100 which is the computer's address, it works.

I found public func enableBroadcast() in UDPClient and I edit var client: UDPClient to public in OSCClient.swift at line 16.
Then, call func enableBroadcast() before call public func send(_ element: OSCElement) in OSCClient, it works.

Sorry for my broken English :(
Regards

0x0c commented

I describe a detail of my workaround below.

First, in OSCClient.swift, I change like this

screen shot 2019-02-17 at 2 34 32

then, send message like this

let client = OSCClient(address: ipAddress, port: port)
client.client.enableBroadcast()
client.send(OSCMessage(...))

Is there any reason without call enableBroadcast()?

0x0c commented

Yes, currently it works, but need to edit SwiftOSC, so it is not convenient when using cocoa pods.
Is it possible to merge my code when I send pull request?

0x0c commented

Yes, my workaround is that made the UDPClient public.
I think this change is not good for broadcast messages, because it needs to call client.client.enableBroadcast() before send a message.
I'll edit another way to make more convenient, after that I'll send pull request.

0x0c commented

I send pull request, plz check it ;)

#33