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

net: cannot bind network card to send data on macos #32722

Closed
weiyixuan opened this issue Jun 21, 2019 · 2 comments
Closed

net: cannot bind network card to send data on macos #32722

weiyixuan opened this issue Jun 21, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@weiyixuan
Copy link

go1.11.0
macOS Mojave

I added two default routes that direct all traffic to a single virtual network card. Then I want to send the test program data directly from the physical network card. I first used bind(),but an error occured while establishing the connection: [connect: no route to host]

On Windows and Linux, I can use the bind() function to bind network cards to send data. Is there any way to do it on a MAC?

var netAddr net.Addr

netAddr = &net.TCPAddr{}
netAddr.(*net.TCPAddr).IP = net.ParseIP("xxx.xxx.xxx.xxx")
dialer := net.Dialer{LocalAddr:netAddr}
conn, err := dialer.Dial("tcp", "yyy.yyy.yyy.yyy:mm")
if err != nil {
	log.Println(err)
	return
}
defer conn.Close()
log.Println("conn successful")
@ianlancetaylor ianlancetaylor changed the title cannot bind network card to send data on macos net: cannot bind network card to send data on macos Jun 21, 2019
@ianlancetaylor
Copy link
Contributor

CC @mikioh

@dmitshur dmitshur added this to the Go1.14 milestone Jun 23, 2019
@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin labels Jun 23, 2019
@weiyixuan
Copy link
Author

Is there a temporary solution?

@golang golang locked and limited conversation to collaborators Jul 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
None yet
Development

No branches or pull requests

4 participants