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

The way to determine tcp/unix may be not so right. #1

Open
ckrissun opened this issue Jun 23, 2014 · 2 comments
Open

The way to determine tcp/unix may be not so right. #1

ckrissun opened this issue Jun 23, 2014 · 2 comments

Comments

@ckrissun
Copy link

Take a look at this:

  n := "tcp"
  if strings.Contains(cfg.Addr, "/") {
      n = "unix"
  }

When cfg.Addr equals to ./server.sock, everything is ok. But what happen when cfg.Addr is server.sock? Absolutely, something goes wrong.

I notice that, when net.ResolveTCPAddr returns an error, then we can say cfg.Addr is a unix address

  n := "tcp"
  if _, err := net.ResolveTCPAddr("tcp", cfg.Addr); err != nil {
      n = "unix"
  }

Thanks!

@siddontang
Copy link
Owner

I see some other apps use above way to select tcp network and don't think it is a big problem because the config address is set by yourself, if you set invalid, dial will be error, you will be responsible for your configuration.

Thanks you!

@ckrissun
Copy link
Author

Yeah, I see. It's really the user's responsibility to do that. Maybe I just want to make everything right as possible as i can. Thank you.

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

No branches or pull requests

2 participants