vb.net联网 vb net

使用vb.net如何访问服务器上的数据库用ADO接口就可以vb.net联网,TCP/IP协议vb.net联网,设定数据库服务器vb.net联网的IP地址,数据库名,用户名,密码就可以连接 。
求大神指点vb.net 怎么判断 网络是否连接 和取本机局域网IP和互联网IP你这段代码可以获得该主机名下的所有ip , 每个ip地址都是有类型簇的,可以区别本地地址和网络地址、ip6地址 。
你获取索引为0的ip,不一定是正确的网络地址,它有时顺序在中间,在后面 。
应该获取所有ip,再通过ip地址簇类型区分
判断连接本身有一个函数,不过有时没联网也是真 。
可以用ping,ping百度、ping访问速度快、不经常维护断线的网络主机 。
用vb.net实现网络通信用 vb.net socket通信
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
【vb.net联网 vb net】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如何判断电脑是否已连接到网络?Microsoft.VisualBasic.Devices.Network.IsAvailable As Boolean
生成实例后可以通过此属性来获取是否联网的值,True代表已联网 , False代表没有联网
Microsoft.VisualBasic.Devices.Network.NetworkAvailabilityChanged(ByVal Object, ByVal Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs)
该事件是在电脑断开/连上互联网是引发的
其中:
e.IsNetworkAvailable
的功能同Microsoft.VisualBasic.Devices.Network.IsAvailable
实例:
Dim netListener As New Microsoft.VisualBasic.Devices.Network '生成实例
If netListener.IsAvailable = True Then
MsgBox("已联网")
Else
MsgBox("未联网")
End If
NetworkAvailabilityChanged实例:
WithEvents netListener As New Microsoft.VisualBasic.Devices.Network '生成实例
Private Sub OnNetworkChanged(ByVal Object, ByVal Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs)Handles netListener.NetworkAvailabilityChanged
If e.IsNetworkAvailable = True Then
MsgBox("已联网")
Else
MsgBox("未联网")
End If
End Sub
求大神指点vb.net,知道了对方互联网IP 怎么判断对方的这个IP 是否断开了呢? 就是断网的意思病情分析:

推荐阅读