gpt4 book ai didi

python - TCP-Socket 到虚拟机的 IP 地址

转载 作者:可可西里 更新时间:2023-11-01 02:54:30 26 4
gpt4 key购买 nike

我想在我的 windows-pc 和 linux 虚拟机之间设置套接字通信。 Windows 机器是服务器。我编写了一个在 winpc 上设置服务器的 C++ 程序和一个在 VM 上设置客户端的 Python 程序,但我如何连接它们?我正在使用 SOCK_STREAMAF_INET,所以我需要一个 portnr 和 ip 地址来连接到服务器。我只是想知道我应该使用什么 IP 地址,因为它不适用于 IPv4,这是因为 IP 地址错误还是因为我的程序错误?

编辑 1:抱歉数据不足:

我使用 Oracle Virtual Box,其网络配置设置为默认 NAT。当我在主机(windows)cmd 中运行 ipconfig 时。我得到了多个 IP 地址:

Windows IP Configuration


Wireless LAN adapter Wireless Network Connection:

Media State . . . . . . . . . . . : *
Connection-specific DNS Suffix . : *

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . : ********
Link-local IPv6 Address . . . . . : *
IPv4 Address. . . . . . . . . . . : *
Subnet Mask . . . . . . . . . . . : *
Default Gateway . . . . . . . . . : *

**Ethernet adapter VirtualBox Host-Only Network:

Connection-specific DNS Suffix . :*
Link-local IPv6 Address . . . . . : *
Autoconfiguration IPv4 Address. . : *
Subnet Mask . . . . . . . . . . . : '*
Default Gateway . . . . . . . . . :***

Tunnel adapter isatap.{*}:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Tunnel adapter 6TO4 Adapter:

Connection-specific DNS Suffix . : ********
IPv6 Address. . . . . . . . . . . : *
Default Gateway . . . . . . . . . :

Tunnel adapter isatap.{5289AB9F-2C9F-4CBE-B826-149B3CFBB45F}:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :*

Tunnel adapter isatap.******:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : *******

Tunnel adapter Teredo Tunneling Pseudo-Interface:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :*

我倾向于得出结论,“以太网适配器 VirtualBox Host-Only Network”下的 IPv6 地址是正确的。我试过 ping LAN 地址和 VirtualBox 仅主机网络地址,它们都产生了结果。我也曾在终端中尝试过 tracerout,但两者都不起作用。有什么想法`?

最佳答案

我使用“以太网适配器本地连接,链接到链接 IPv6”。阅读 NAT 后,我想这是有道理的!

关于python - TCP-Socket 到虚拟机的 IP 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25429062/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com