WSK - Reusing socket return error 0xc0000184

Hello,

I am developing WDF driver using Winsock Kernel module connecting network. I have encounter problem when I try to reuse socket. I am successfully creating, binding and connecting socket. After that I am disconnecting socket with WskDisconnect function with success status. However when I try to reconnect using same socket I get error 0xc0000184. Any ideas why I can’t reuse my socket? Binding fails as well.

Cheers.

nb3m wrote:

I am developing WDF driver using Winsock Kernel module connecting network. I have encounter problem when I try to reuse socket. I am successfully creating, binding and connecting socket. After that I am disconnecting socket with WskDisconnect function with success status. However when I try to reconnect using same socket I get error 0xc0000184. Any ideas why I can’t reuse my socket? Binding fails as well.

I don’t know the kernel equivalent, but in user-mode sockets, you have
to set the socket option SO_REUSEADDR (and SO_REUSEPORT if it is
defined) to reuse a TCP socket before the normal (lengthy) timeout.

Hi Tim,

As far as I know, Winsock kernel does not have such option. It is matter of two functions I am calling, at first WskConnect and then WskDisconnect. First time you call them is ok, but when you try to reconnect it fails. Connecting to different port does not work as well.

Did you actually try Mr Roberts’ suggestion? https://docs.microsoft.com/en-us/windows-hardware/drivers/network/so-reuseaddr

@Tim_Roberts It’s not working. I receive same error. Any thoughts?

nb3m wrote:

@Tim_Roberts It’s not working. I receive same error. Any thoughts?

Are you calling WskSocketConnect, or are you calling WskSocket, WdkBind,
and WskConnect?  Maybe (and I’m just making this up now) you need to set
the socket option before you bind and connect. That’s true in user mode.

@Tim_Roberts I am caling WskSocket, WskControlSocket, WskBind and WskConnect (All successful). I don’t want to use WskSocketConnect because it will complicate my code.

Bump! Any idea what could possibly be root cause?

Still no solution. Anyone who could help with that?

https://learn.microsoft.com/en-us/windows-hardware/drivers/network/so-reuseaddr