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

Support IPv4 and IPv6 at same socket #14

Open
Lybecker opened this issue Aug 24, 2018 · 5 comments
Open

Support IPv4 and IPv6 at same socket #14

Lybecker opened this issue Aug 24, 2018 · 5 comments
Labels

Comments

@Lybecker
Copy link
Contributor

Current implementation of CoapUdpEndPoint does not support IPv4 and IPv6 at the same time.

Actually the default constructor CoapUdpEndPoint is hardcoded to IPv4 with the IPAddress.Any (Any means IPv4 and IPv6Any means IPv6)
The samples was ailing due to this, so I set out to figure out why and lean myself. So I wrote a blog post:
http://www.lybecker.com/blog/2018/08/23/supporting-ipv4-and-ipv6-dual-mode-network-with-one-socket/

@NZSmartie
Copy link
Owner

Ah, good catch. I haven't been able to test with IPv6 yet, i'll get onto that soon.

@NZSmartie NZSmartie added the bug label Aug 24, 2018
@Lybecker
Copy link
Contributor Author

Lybecker commented Aug 24, 2018 via email

@NZSmartie
Copy link
Owner

If you submit what you have so far as a PR, i can investigate the tests

@andygikling
Copy link

andygikling commented May 10, 2019

@Lybecker, @NZSmartie

I'm testing the out of the box client and server with your merged changes under VS2019. I'm getting a curious exception related to the section of code that was changed above (I think).

System.Net.Sockets.SocketException: 'An invalid argument was supplied'

This happens immediately when the client tries to send the hello put to the server. The full stack trace I get in my client window is this:

Exception caught: System.Net.Sockets.SocketException (0x80004005): An invalid argument was supplied
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at CoAPNet.Udp.CoapUdpEndPoint.BindAsync() in C:\Dev\CoAP.Net.git\src\CoAPNet.Udp\CoapUdpEndPoint.cs:line 100
at CoAPNet.Udp.CoapUdpEndPoint.d__37.MoveNext() in C:\Dev\CoAP.Net.git\src\CoAPNet.Udp\CoapUdpEndPoint.cs:line 171
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CoAPNet.CoapClient.d__41.MoveNext() in C:\Dev\CoAP.Net.git\src\CoAPNet\CoapClient.cs:line 502
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CoAPNet.CoapClient.d__40.MoveNext() in C:\Dev\CoAP.Net.git\src\CoAPNet\CoapClient.cs:line 464
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at CoAPNet.CoapClient.<SendAsync>d__37.MoveNext() in C:\Dev\CoAP.Net.git\src\CoAPNet\CoapClient.cs:line 406 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at CoAPDevices.Program.

d__0.MoveNext() in C:\Dev\CoAP.Net.git\samples\SimpleClient\Program.cs:line 44
Press to exit

Do you have any insights for this? I haven't looked into it yet unfortunately. I'm just shopping for .net coap libraries. I'm a little surprised the demo client/server didn't work out of the box.

Thoughts?

@Lybecker
Copy link
Contributor Author

It is due to the client tries to bind twice to the same endpoint in two different threads. I don't know why

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

No branches or pull requests

3 participants