msantos / procket

Erlang interface to low level socket operations
http://blog.listincomprehension.com/search/label/procket
BSD 3-Clause "New" or "Revised" License
283 stars 80 forks source link

Function to build `struct sockaddr`? #32

Open qwertystop opened 7 years ago

qwertystop commented 7 years ago

That seems like the biggest usability difficulty at the moment: The need to pass a struct sockaddr when there's no way to make one except by manually concatenating bitstrings/binaries.

I could do this myself but it would take a while, because I'm rather busy at the moment. Also I can't make it work cross-platform. Figured I'd put the issue up in case someone else wanted to take it, instead of leaving it to later and forgetting.

msantos commented 7 years ago

It's a little tricky since a sockaddr is a pointer to different types of sockaddrs with a common header.

One way to do it would be to create a new sockaddr library:

sockaddr:in(Port, IPv4addr)
sockaddr:in6(Port, FlowInfo, IPv6addr, ScopeId)
....

I will add it to my TODO list!