
正文
udp源码vb.net,udp代码实现
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net 如何获取某个进程的UDP连接信息(要有目标ip和port)
private void MyPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
public static boolean isNumeric(String str){
if(str.matches("//d*"){
return true;
}else{
return false;
}
}
相关问答
Q1: vb.net udpclient 发送大文件循环问题
'缓冲区长度
Const BufLen As Integer=800
'包发送间隔
Const Interval As Integer=62
'缓冲区
Dim buf As Byte()=Nothing
'远程(目的)网络端点
Dim remoteep As IPEndPoint=Nothing
'如果你已将s定义为类的成员变量(实例或共享),注释掉下面这句
Dim s As UdpClient=Nothing
Dim willread As Integer
Try
buf=New Byte(BufLen-1) {}
s=New UdpClient()
' TextBox1.Text包含远程(目的)主机的IP地址
' TextBox2.Text包含远程(目的)主机的端口号
remoteep=New IPEndPoint(IPAddress.Parse(Trim(TextBox1.Text)),CInt(TextBox2.Text))
' Label2.Text包含要发送的文件的路径
Using fs As New FileStream(Label2.Text,FileMode.Open,FileAccess.Read)
While fs.Positionfs.Length
willread=BufLen
If fs.Length-fs.PositionBufLen Then
willread=CInt(fs.Length-fs.Position)
End If
fs.Read(buf,0,willread)
s.Send(buf,willread,remoteep)
Thread.Sleep(Interval)
End While
End Using
Catch ex As Exception
MsgBox(ex.ToString())
Finally
If s IsNot Nothing Then
s.Close()
End If
End Try
Q2: C#/VB.NET中 UDP协议连接服务器问题...运行没出错..但是收不到信息.
服务器先进行
Bind ()绑定服务器的端口
然后BeginReceive接受客户端发送的数据
客户端Bind ()绑定客户端接受和发送数据的端口
SendTo()来发送数据就可以
不需要进行BeginConnect,因为UDP不需要连接
Q3: 求一个VB.NET进行局域网内UDP广播的源代码例子
给你个udp多播例子,广播不是很清楚,呵呵
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form
Dim port As String
Dim ipadd As String
Dim ipend As IPEndPoint
Dim sendudp As New UdpClient()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim ipadress As IPAddress
ipadress = IPAddress.Parse(TextBox1.Text)
'sendport = Int32.Parse(TextBox2.Text)
'ipend = New IPEndPoint(ipadress, sendport)
Try
sendudp.JoinMulticastGroup(ipadress)
MessageBox.Show("启动完成!")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub





