TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
latika singh
NA
31
33.8k
Win Forms UDP application
Feb 7 2012 10:10 AM
Hi All,
I am trying to establish a connection through UDP to a hardware device I want to talk to. Following is my implementation on the win forms:
I catches exception and gives the error message when I try to send the data. It says: "
Cannot send packets to an arbitrary host while connected
."
Pl advise.
Try
Dim dataSend() As Byte = New Byte() {}
myEP = New IPEndPoint(IPAddress.Parse("192.168.2.50"), 20000)
myUDP.Connect(myEP)
If myUDP.Client.Connected Then
lblStatus.Text = "Connection successful"
End If
lblStatus.Text = "Converting Data"
dataSend = Encoding.ASCII.GetBytes(txtDatatoSend.Text)
If dataSend.Length = 0 Then
lblStatus.Text = "Send textbox cannot be left blank"
Else
lblStatus.Text = ""
End If
If myUDP.Client.Connected Then
myUDP.Send(dataSend, dataSend.Length, myEP)
End If
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
Reply
Answers (
3
)
Multiple instance of User-Control in a Windows Form
Add item to listview in backgroundworker without refreshing the listview