关于vb.net取网卡流量的信息

用vb.net实现网络通信

用 vb.net socket通信

创新互联建站专注于企业全网营销推广、网站重做改版、阳明网站定制设计、自适应品牌网站建设、成都h5网站建设电子商务商城网站建设、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为阳明等各大城市提供网站开发制作服务。

Dim th As Threading.Thread

2 Dim tcpl As System.Net.Sockets.TcpListener

3

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

5 th = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MyListen))

6 th.Start()

7 End Sub

8

9 Public Sub SendMessage()Sub SendMessage(ByVal IP As String, ByVal SendMsg As String)

10 Try

11 If IP "" Then

12 Dim tcpc As New System.Net.Sockets.TcpClient(IP, 5656)

13 Dim tcpStream As Net.Sockets.NetworkStream = tcpc.GetStream

14 Dim reqStream As New IO.StreamWriter(tcpStream)

15 reqStream.Write(SendMsg)

16 reqStream.Flush()

17 tcpStream.Close()

18 tcpc.Close()

19 End If

20 Catch ex As Exception

21 MsgBox(ex.Message.ToString)

22 End Try

23 End Sub

24 Private Sub MyListen()Sub MyListen()

25 Try

26 Dim ipAddress As System.Net.IPAddress = System.Net.Dns.Resolve(System.Net.Dns.GetHostName).AddressList(0)

27 tcpl = New System.Net.Sockets.TcpListener(ipAddress, 5656)

28 tcpl.Start()

29 While True

30 Dim s As System.Net.Sockets.Socket = tcpl.AcceptSocket()

31 Dim MyBuffer(1024) As Byte

32 Dim i As Integer

33 i = s.Receive(MyBuffer)

34 If i 0 Then

35 Dim lstrRec As String

36 Dim j As Integer

37 For j = 0 To i - 1

38 TextBox1.Text += Chr(MyBuffer(j)) ","

39 Next

40 End If

41 End While

42 Catch ex As Exception

43 MsgBox(ex.Message.ToString)

44 End Try

45 End Sub

46

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

48 SendMessage("192.168.0.61", TextBox2.Text)

49 End Sub

VB.net怎样从网络中逐个读取数据

Public Function webCaptureContent(ByVal mWebsiteUrl As String, ByVal mWebsiteType As Boolean) As String

'启动一次具体的数据采集工作,返回采集到的HTML内容:要求必须输入带://的全地址数据

On Error Resume Next

Dim Str_WebContent As String = "请输入查找网站地址."

Dim wb As WebClient = New WebClient() '//创建一个WebClient实例

If mWebsiteUrl.IndexOf("://") 0 Then

'//获取或设置用于对向 Internet 资源的请求进行身份验证的网络凭据。(可有可无)

wb.Credentials = CredentialCache.DefaultCredentials

'//从资源下载数据并返回字节数组。(加@是因为网址中间有"/"符号)

Dim pagedata As Object = wb.DownloadData(mWebsiteUrl)

'//转换字符

If mWebsiteType Then

Str_WebContent = Encoding.Default.GetString(pagedata)

Else

Str_WebContent = Encoding.UTF8.GetString(pagedata)

End If

End If

Return Str_WebContent '提取出来新闻内容,删除Body前后的多余内容,同时补充上该 Body标记,形成完整的内容 Str_WebContent '

End Function

求大神指点vb.net 怎么判断 网络是否连接 和取本机局域网IP和互联网IP

你这段代码可以获得该主机名下的所有ip,每个ip地址都是有类型簇的,可以区别本地地址和网络地址、ip6地址。

你获取索引为0的ip,不一定是正确的网络地址,它有时顺序在中间,在后面。

应该获取所有ip,再通过ip地址簇类型区分

判断连接本身有一个函数,不过有时没联网也是真。

可以用ping,ping百度、ping访问速度快、不经常维护断线的网络主机。

C#如何实现获取网卡的流量?

网卡的流量就是所有的流量,要想获得外网的流量,有两种途径,一是获取网关的数据,二是获取自己电脑上不同IP的流量,计算出所有外网的流量就行了。

第一个方法需要网关的支持,第二种方法估计没办法实现吧,要实时的工作才能检测到所有的流量。

VB 获取本地连接 流量数据

Declare Function GetNetworkParams Lib "iphlpapi.dll" (FixedInfo As Any, pOutBufLen As Long) As Long

Declare Function GetIfTable Lib "iphlpapi.dll" (ByRef pIfTable As MIB_IFTABLE, ByRef pdwSize As Long, _

ByVal bOrder As Long) As Long

Declare Function GetIfEntry Lib "iphlpapi.dll" (pIfRow As MIB_IFROW) As Long

Type MIB_IFROW '保存结果信息

wszName(0 To 511) As Byte '接口名称的Unicode字符串,必须为512字节

dwIndex As Long '接口编号

dwType As Long '接口类型,参看IP_ADAPTER_INFO类型的Type成员

dwMtu As Long '最大传输单元

dwSpeed As Long '接口速度(字节)

dwPhysAddrLen As Long '由bPhysAddr获得的物理地址有效长度

bPhysAddr(0 To 7) As Byte '物理地址

dwAdminStatus As Long '接口管理状态

dwOperStatus As Long '操作状态,以下值之一:

dwLastChange As Long '操作状态最后改变的时间

dwInOctets As Long '总共收到(字节)

dwInUcastPkts As Long '总共收到(unicast包)

dwInNUcastPkts As Long '总共收到(non-unicast包),包括广播包和多点传送包

dwInDiscards As Long '收到后丢弃包总数(即使没有错误)

dwInErrors As Long '收到出错包总数

dwInUnknownProtos As Long '收到后因协议不明而丢弃的包总数

dwOutOctets As Long '总共发送(字节)

dwOutUcastPkts As Long '总共发送(unicast包)

dwOutNUcastPkts As Long '总共发送(non-unicast包),包括广播包和多点传送包

dwOutDiscards As Long '发送丢弃包总数(即使没有错误)

dwOutErrors As Long '发送出错包总数

dwOutQLen As Long '发送队列长度

dwDescrLen As Long 'bDescr部分有效长度

bDescr(0 To 255) As Byte '接口描述

End Type

Type MIB_IFTABLE '包含结果表

dwNumEntries As Long '当前网络接口的总数

MIB_Table(9) As MIB_IFROW '指向一个包含MIB_IFROW类型的指针

End Type

Sub Test()

Dim Net As MIB_IFTABLE

LenIfT = Len(Net)

RValue = GetIfTable(Net, LenIfT, True)

'由Net.dwNumEntries获得接口数量,然后用for…next循环获取每个接口信息:

For I = 1 To Net.dwNumEntries - 1

With Net.MIB_Table(I)

Debug.Print

Debug.Print "----" Time "----"

Debug.Print "接口编号:" .dwIndex

Debug.Print "接口速度:" .dwSpeed

Debug.Print "接口状态:" .dwAdminStatus

Debug.Print "操作状态:" .dwOperStatus

Debug.Print "收到字节:" .dwInOctets

For XI = 1 To .dwPhysAddrLen - 1

TXX = TXX Format(Hex(.bPhysAddr(XI)), "00")

Next

If TXX "" Then Debug.Print "网卡地址:"; TXX

End With

Next

End Sub

vb.net怎么获取网卡MAC地址?

Public Function EnumNetworkAdapters() As String

Try

Dim query As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")

Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()

Dim mo As New System.Management.ManagementObject

For Each mo In queryCollection

If IsDBNull(mo.Item("Description")) = False Then

EnumNetworkAdapters = mo.Item("Description") "|||"

End If

If IsDBNull(mo.Item("macaddress")) = False Then

If mo.Item("macaddress") "" Then

EnumNetworkAdapters = mo.Item("macaddress") "|||"

End If

End If

If IsDBNull(mo.Item("IPAddress")) = False Then

Dim temp As String

temp = Join(mo.Item("IPAddress"), ".")

If temp "" Then

EnumNetworkAdapters = temp "|||"

End If

End If

Next

Catch err A* **ception

EnumNetworkAdapters = err.Message err.StackTrace

End Try

End Function


网页标题:关于vb.net取网卡流量的信息
链接URL:http://bzwzjz.com/article/hcehcs.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 上市集团网站建设 网站制作 广安网站设计 成都企业网站建设公司 成都网站建设 网站建设公司 网站制作报价 定制网站建设多少钱 重庆网站设计 成都网站建设 网站设计制作 营销网站建设 成都网站制作 网站建设公司 成都网站制作 成都网站建设推广 成都网站设计 手机网站制作 成都网站设计 成都网站制作 企业网站建设公司 成都网站建设