vb.net设定ip vbnet lib

vb.net怎样设置ie浏览器的代理服务器地址建议你使用注册表的API进行修改
封装两个NET函数给你
private string GetReg(string RegPath)取得注册表项内容
{
string str="";
RegistryKey hkml = Registry.LocalMachine;
RegistryKey software = hkml.OpenSubKey("SOFTWARE",true);
RegistryKey aimdir = software.OpenSubKey("krabs",true);
if (aimdir != null)
{
if (aimdir.GetValue(RegPath) != null)
str = aimdir.GetValue(RegPath).ToString();
if (str != null)
return str;
return null;
}
return null;
}
private bool SetReg(string RegPath,string Data)//设置注册表内容
{
RegistryKey reg = Registry.LocalMachine;
RegistryKey software = reg.OpenSubKey("SOFTWARE", true);
RegistryKey aimdir1 = software.CreateSubKey("krabs");
if (aimdir1 == null)
return false;
aimdir1.SetValue(RegPath, Data);
return true;
}
VB.NET的TCP/IP协议 怎么弄Dim th As Threading.Thread
2Dim tcpl As System.Net.Sockets.TcpListener
3
4Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
5th = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MyListen))
6th.Start()
7End Sub
8
9Public Sub SendMessage()Sub SendMessage(ByVal IP As String, ByVal SendMsg As String)
10Try
11If IP"" Then
12Dim tcpc As New System.Net.Sockets.TcpClient(IP, 5656)
13Dim tcpStream As Net.Sockets.NetworkStream = tcpc.GetStream
14Dim reqStream As New IO.StreamWriter(tcpStream)
15reqStream.Write(SendMsg)
16reqStream.Flush()
17tcpStream.Close()
18tcpc.Close()
19End If
20Catch ex As Exception
21MsgBox(ex.Message.ToString)
22End Try
23End Sub
24Private Sub MyListen()Sub MyListen()
25Try
26Dim ipAddress As System.Net.IPAddress = System.Net.Dns.Resolve(System.Net.Dns.GetHostName).AddressList(0)
27tcpl = New System.Net.Sockets.TcpListener(ipAddress, 5656)
28tcpl.Start()
29While True
30Dim s As System.Net.Sockets.Socket = tcpl.AcceptSocket()
31Dim MyBuffer(1024) As Byte
32Dim i As Integer
33i = s.Receive(MyBuffer)
34If i0 Then
35Dim lstrRec As String
36Dim j As Integer
37For j = 0 To i - 1
38TextBox1.Text= Chr(MyBuffer(j))","
39Next
40End If
41End While
42Catch ex As Exception
43MsgBox(ex.Message.ToString)
44End Try
45End Sub
46
47Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
48SendMessage("192.168.0.61", TextBox2.Text)
49End Sub
如何在vb,net用程序修改ip地址做exe程序获取本机IP地址用
System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList
做web程序获取客户端的IP地址用
HttpContext.Current.Request.ServerVariables("REMOTE_ADDR"])
vb.net TCP协议服务端ip怎么写才能使客户端能通过公网连接进来?需要出口设备进行映射内部地址;或使用打洞技术穿透NAT,但使用TCP打洞非常困难 。
参考
穿透NAT是非常困难的,因为NAT的过程中在出口路由器上的Port已经不是你定义的iPort了,具体是多少也不固定
vb.net 指定IP端口是否开放using System.Net;
if(!string.IsNullOrEmpty(txtPort.Text))
{
IPAddress ip = IPAddress.Parse(txtIp.Text);
IPEndPoint point=new IPEndPoint(ip,int.Parse(txtPort.Text));
try
{
TcpClient tcp=new TcpClient();
tcp.Connect(point);
MessageBox.Show("端口打开");
}catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
通过以上这个方法,只能判断你是否能链接这个端口 。
通过以下这个方法,能判断端口是否开放
public static void GetTcpConnections()
{
IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();
string str="";
foreach (TcpConnectionInformation t in connections)
{
str ="Local endpoint:"t.LocalEndPoint.ToString() ",";
str ="Remote endpoint:"t.RemoteEndPoint.ToString() ",";
str =t.State.ToString() ",";
}
MessageBox.Show(str);
}
【vb.net设定ip vbnet lib】vb.net设定ip的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于vbnet lib、vb.net设定ip的信息别忘了在本站进行查找喔 。

    推荐阅读