本文介绍了指定在C#中使用的TcpClient /插座使用即将离任的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和分配给网络适配器的多个IP地址的服务器。

I've a server with several IP Addresses assigned to the network adapter.

在服务器是客户端应用程序通过的TcpClient连接到另一台服务器上的应用程序。对于所有传出的通讯我的服务器默认的IP地址已被使用,但是这一个应用程序,我想呼出通信是送出去的另一本地IP地址。

On that server is a client app to connect to another server app via TCPClient. For all outgoing communications my servers default IP address is being used, however for this one application I'd like the outgoing communication to be send out on another local IP address.

传达到指定的其他本地分配IP时,这可能吗?

Is it possible when communicating out to specify another locally assigned IP?

我试图使远程服务器上的应用程序想从另一台IP的,因此将通过防火墙等....

I'm trying to make the remote server app think it's from another IP so it will pass through firewalls etc....

在此先感谢

推荐答案

您可以使用的TcpClient 的接受本地端点地址构造:

You can use the constructor of TcpClient that accepts a local endpoint address:

TcpClient c=new TcpClient(new System.Net.IPEndPoint(...));

例如:

TcpClient c=new TcpClient(new IPEndPoint(IPAddress.Parse("192.168.1.1"), 0);

参考:

这篇关于指定在C#中使用的TcpClient /插座使用即将离任的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:37