OpenUdp
OpenUdp is used to establish a connection with a remote server using UDP.
Syntax
OpenUdp()
Returns
Socket Object.
Example
This script connects with a DNSA database used by TCP/IP networks that enables the translation of hostnames into IP numbers and to provide other domain related information. server, specified by the IP variable and runs a query for www.gfi.com and then displays the result:
Function Main
Dim SocketObject As Object
Dim ip As String
Dim port As String
Dim rawdata As Variant
Dim Response As Variant
Ip = "172.16.130.40"
Port = "53"
strRequest="www.gfi.com"
rawdata = Array(0,3,1,0,0,1,0,0,0,0,0,0,3,&H77, &H77, &H77, &H03, &H67, &H66, &H69, &H03, &H63, &H6F,&H6D, 0,0,1,0,1)
'^^^^^^^^^^
'This part is the packet header of our request, it includes informations such as flags
'^^^^^^^^^^
'This is the request itself, www.gfi.com, note that '.' are 'represented as &H03 instead of &H2E
'^^^^^^^^^^
'This is the End header of our packet
Set SocketObject = Socket.OpenUdp()
If Not SocketObject is Nothing Then
'check to see that the Object returned successfully
SocketObject.SendTo IP,port,rawdata
Response = SocketObject.Recv(1024)
For a = UBound(response)-3 To UBound(response)
echo(Response(a))
If a <> UBound(response) Then
echo(".")
End If
Next a
SocketObject.Close
End If
End Function