Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DatagramSocket and friends on Native #3

Open
wants to merge 1 commit into
base: feature/polling
Choose a base branch
from

Conversation

armanbilge
Copy link
Owner

@lavrov I think you've been waiting for this one 😄 I've published it as 3.8-a43eaac. If you have a chance to try it, please let me know if there are any issues!

It's based on typelevel#3240, but I'll wait to PR it separately because that one is so big already.

@lavrov
Copy link
Sponsor

lavrov commented Jul 4, 2023

@armanbilge you are right, UDP support is a blocker for one of my projects. This made me follow recent development in polling runtime space and it looks great!

Is this supposed to work on MacOS? I quickly tried your build and got

java.io.IOException: Can't assign requested address
	at java.lang.StackTrace$.currentStackTrace$$anonfun$1(Unknown Source)
	at java.lang.StackTrace$$$Lambda$2.applyVoid(Unknown Source)
	at apply @ fs2.io.net.FdPollingDatagramSocket.write$$anonfun$1(Unknown Source)
	at pollWriteRec @ fs2.io.net.FdPollingDatagramSocket.write(Unknown Source)
	at main @ Main.main(Unknown Source)
	at flatMap @ Main$.run$$anonfun$1(Unknown Source)

UPDATE:
It seems the problem was in a bind address: i had to set it explicitly to ip"0.0.0.0":

Network[IO].openDatagramSocket(Some(ip"0.0.0.0"))

I will give it more extensive testing later on.

@armanbilge
Copy link
Owner Author

It seems the problem was in a bind address: i had to set it explicitly to ip"0.0.0.0"

Oh, that's interesting. Thanks for trying that, I will investigate it too.

If bind address is None it should use loopback, maybe that is behaving strangely on macOS 🤔

address <- Resource.eval(address.fold(IpAddress.loopback)(_.resolve))

@lavrov
Copy link
Sponsor

lavrov commented Jul 4, 2023

If bind address is None it should use loopback, maybe that is behaving strangely on macOS 🤔

JVM version promises binding to "all interfaces".

https://github.com/typelevel/fs2/blob/d7f1b71a8d7badb8a7ef0a8a5468807f9e384358/io/js-jvm/src/main/scala/fs2/io/net/DatagramSocketGroup.scala#L33

@armanbilge
Copy link
Owner Author

Aha, thanks, that would be the problem 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants