网站建设资讯

NEWS

网站建设资讯

vb点虐 连接宽带 vb如何联网

怎么用vb点虐 获取无线网络的MAC地址

你可以使用WMI来获取MAC ID。。加上一些特定的条件也可以实现获取WLAN MAC_ID

目前创新互联建站已为上1000家的企业提供了网站建设、域名、网络空间、网站托管、服务器租用、企业网站设计、太原网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

vb2010 (vb点虐 )Socket套接字当网络中断时或服务器意外关机,客户端如何自动重新连接服务端

发送接收的过程都放在Try...Catch里面,一旦连接中断,就会出错,此时可以关闭现有连接,重新连服务端

VB.NET 2003中 想做一个基于TCP/IP的网络通信程序

就可以了,我有一段不太成熟的代码:

Imports System.Net

Imports System.Net.Sockets

Imports System.Threading

Imports System.IO

Public Class Form1

Dim TCPListenerRun, TCPClientRun As Boolean

Dim ControlTCPClient, ServerClient As TcpClient

Dim ControlTCPListener As TcpListener

Dim TCPClientT, TCPListenerT As Thread

Private ControlStream, SControlStream As NetworkStream

Private ControlReadStream, SControlReadStream As StreamReader

Private ControlWriteStream, SControlWriteStream As StreamWriter

'异步委托

Private Delegate Sub InvokeDelegate(ByVal iMessage As String)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try

If TCPListenerRun Then

TCPListenerT.Abort()

ControlTCPListener.Stop()

TCPListenerRun = False

Button1.Text = "启动服务端 "

TextBox2.AppendText( "服务器已停止! " vbCrLf)

Else

ControlTCPListener = New TcpListener(IPAddress.Parse( "127.0.0.1 "), 13000)

ControlTCPListener.Start()

TCPListenerT = New Thread(AddressOf Listen)

TCPListenerT.Start()

TextBox2.AppendText( "等待连接... " vbCrLf)

TextBox2.AppendText( "服务器已启动! " vbCrLf)

TCPListenerRun = True

Button1.Text = "停止服务端 "

End If

Catch ex As Exception

TextBox2.AppendText(ex.Message vbCrLf)

End Try

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Try

If TCPClientRun Then

TCPClientT.Abort()

ControlTCPClient.Close()

TCPClientRun = False

Button2.Text = "启动客户端 "

Else

ControlTCPClient = New TcpClient(New IPEndPoint(IPAddress.Parse( "127.0.0.1 "), 13001))

ControlTCPClient.Connect(New IPEndPoint(IPAddress.Parse( "127.0.0.1 "), 13000))

TCPClientRun = True

Button2.Text = "停止客户端 "

TCPClientT = New Thread(AddressOf Receive)

TCPClientT.Start()

ControlStream = ControlTCPClient.GetStream()

ControlReadStream = New StreamReader(ControlStream)

ControlWriteStream = New StreamWriter(ControlStream)

End If

Catch ex As SocketException

'If ex.ErrorCode = 10048 Then

ControlTCPClient.Close()

'End If

TCPClientRun = False

Button2.Text = "启动客户端 "

TextBox2.AppendText(ex.Message vbCrLf)

End Try

End Sub

Private Sub Listen()

ServerClient = ControlTCPListener.AcceptTcpClient

TextBox2.BeginInvoke(New InvokeDelegate(AddressOf InvokeMethod_Receive), "成功连接... ")

SControlStream = ServerClient.GetStream()

SControlReadStream = New StreamReader(SControlStream)

SControlWriteStream = New StreamWriter(SControlStream)

While True

TextBox2.BeginInvoke(New InvokeDelegate(AddressOf InvokeMethod_Receive), SControlReadStream.ReadLine())

End While

End Sub

Private Sub Receive()

While True

TextBox2.BeginInvoke(New InvokeDelegate(AddressOf InvokeMethod_Receive), ControlReadStream.ReadLine())

'Console.WriteLine(ControlTCPClient.Available)

End While

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

TCPListenerRun = False

TCPClientRun = False

End Sub

Private Sub InvokeMethod_Receive(ByVal iMessage As String)

TextBox2.AppendText(iMessage vbCrLf)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

ControlWriteStream.WriteLine(TextBox1.Text)

ControlWriteStream.Flush()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

SControlWriteStream.WriteLine(TextBox3.Text)

SControlWriteStream.Flush()

End Sub

End Class


分享题目:vb点虐 连接宽带 vb如何联网
分享链接:http://cdweb.net/article/ddjddhd.html