microsoft / go-winio

Win32 IO-related utilities for Go
MIT License
939 stars 181 forks source link

LocalAddr() and/or RemoteAddr() should return different values for each connection #273

Open hansinator opened 1 year ago

hansinator commented 1 year ago

I need to use LocalAddr() and/or RemoteAddr() on a pipe connection to log the client in a multiple-client setup. Unfortunately it always returns the same string for all connections on the same pipe address.

What I do now after accept is rather ugly and needs special handling for different connection types:


type fdInterface interface {
    Fd() uintptr
}
...
        c, err := l.Accept()
        if err != nil {
            return err
        }

        // create a sub-logger for each client connection
        cl := log.Logger.With().Str("client", fmt.Sprint(c.(fdInterface).Fd())).Logger()

Can you imagine a way how to remedy the situation? I'd submit a PR if we can agree on smthng.