thank you @dave i know i have a lot to learn and i'm looking for who to teach me. I installed Microsoft Visual Web Developer IDE on my machine which can be used to write ASP.NET website. I wrote this code yesterday inside the IDE in the Deafult.aspx page.
<%@ Page Language="vb" %>
<%@ Import Namespace="System.Net.Sockets" %>
<%@ Import Namespace="System.Net" %>
<script runat="server" >
Protected Sub pgLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim recClient As UdpClient
Dim ipEndPt As New IPEndPoint(IPAddress.Any, 0)
recClient = New UdpClient(9201)
Dim receivedByte As Byte() = recClient.Receive(ipEndPt)
Dim strReturned As String = Encoding.ASCII.GetString(receivedByte)
recClient.Connect("127.0.0.1", 9200)
Dim boSend As Byte() = Encoding.ASCII.GetBytes(strReturned)
recClient.Send(boSend, boSend.Length)
Response.Write("Message sent!")
recClient.Close()
End Sub
i also wrote another program using VB.NET IDE. Here is the code:
Shared client As New UdpClient
Shared receivePoint As IPEndPoint
Public Sub Main()
receivePoint = New IPEndPoint(New IPAddress(0), 0)
client = New UdpClient(9200)
Dim thread As Thread = New Thread(New ThreadStart(AddressOf WaitForPackets))
thread.Start()
Dim packet As String = "Hello Server"
Console.WriteLine("Sending packet containing: ")
Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes(packet)
client.Connect("127.0.0.1", 9201)
client.Send(data, data.Length)
Console.WriteLine("Packet sent")
End Sub
Public Sub WaitForPackets()
While True
Console.WriteLine("receiving.........")
Dim data As Byte() = client.Receive(receivePoint)
Console.WriteLine("Packet received:" & _
vbCrLf & "Length: " & data.Length & vbCrLf & _
System.Text.Encoding.ASCII.GetString(data))
End While
End Sub
Now, after executing the asp.net code, it opens in my browser and started loading..(infinite loading) and i concluded in my mind that "it is waiting for client to connect". While the page is loading in my browser, i run the second vb.net code and behold, it sends the message to the asp.net code and gets it back as response.
Now, the reason why i concluded in my earlier post that ASP.NET can work is because of the little exercise i performed which i just explained above. Now that i know that ASP.NET cannot be used, is there any other language that can be used to build udp servers aside from PHP?
To cut my long story short, what i am trying to implement is a client (local) that will send message to a udp server (remote) via UDP protocol.
Any help will be appreciated.