Hello,
I have been trying sometime now to just figure out how to make a UDP connection with VB.NET 2008 and can't seem to figure it out. I even found 4 books on VB.NET but don't mention a thing about sockets but talk about web based stuff. I defitaly need to use a UDP socket. In VB6.0 this was easy. I have search the internet and fourms and put some code together to send hello world. But I can't seem to get it to work... The receiving side is a Linux computer which can receive data sent from itself on 127.0.0.1.
If someone could give me some insite i would really appricate it.
thanks
Code:
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Dim clientSocket As New UdpClient
Private Sub ConnectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectButton.Click
End Sub
Private Sub GoLeftButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoLeftButton.Click
Dim bytCommand As Byte() = New Byte() {}
clientSocket.Connect(IPTxt.Text, PortTxt.Text)
bytCommand = Encoding.ASCII.GetBytes("hello world")
clientSocket.Send(bytCommand, bytCommand.Length)
End Sub
End Class
im presuming that this is the client's code. im not exactly sure why it isnt working so can you please elaborate? what are you using to program the linux computer? search for "udp" on msdn.com for more help and even an example. also change this:
I am trying to make a similar program, but am new to VB.net 2008. Would u be able to show me the code of the recieving program which i could use as a reference?
It doesn't matter. The Visual Studio Conversion Wizard converts it perfectly fine for me and it compiles and executes without an issue. I am using Visual Studio 2008 but 2005 should be fine. But if you would like to learn more a better way is to write/copy it yourself into your own project, because as you write you learn and understand stuff you might not see when you just look over it or convert it.
I have a project going, tho its done noticeably different.. I have the client sending the packet.. Im just having issues with the server recieving.. Would u possibly be able to help me through a couple of my errors?
First is the DLL which is the actual classes (TinyServer and TinyClient).
The second project is a windows form project that uses the functions in the DLL.
Its a OOP approach which is the more favorable way to do things in a programming sense when applicable. Its good because you can reuse the code instead of having to write out the functions all again if you need them you just have to import the Tiny.UDP namespace(DLL) and then just create and object of the appropriate class and call the functions/methods.
Please attach your project if you can and ill take a look at it, don't include any executable format files though as there not allowed.