1

I have a cross-platform Golang application which listens on a Unix file socket as follows:

    listener, err := net.Listen("unix", socketFilePath)
    if err != nil {
        return err
    }

When this code runs in Windows (Win10 22H2, specifically), it sometimes fails because another process is already listening on that socket:

listen unix [my socket path]: bind: Only one usage of each socket address 
(protocol/network address/port) is normally permitted.

How do I find which process already is already bound to the socket? I've already verified that no instances of my application's process are running.

My searching led me to various things about open file handles and open network sockets, but AFAICT Windows treats file sockets differently than either of those, so those tools and techniques don't reveal the thing I'm looking for.

Things that didn't solve my problem:

JakeRobb
  • 162

2 Answers2

3

How do I find which process already is already bound to the socket? I've already verified that no instances of my application's process are running.

Your error message is cross-platform as well. Even if the process exits, 'Unix' file-based sockets are not deleted automatically; the process itself is responsible for the unlink() that must be done before a new bind/listen is attempted. Manually deleting the socket should allow you to listen on it again.

grawity
  • 501,077
0

How do I find which process already is already bound to the socket? I've already verified that no instances of my application's process are running.

Use SysInternals TcpView tool.

fpiette
  • 216