ActiveXperts Network Component Udp Object

The Network Component Udp object is based on the Transport Control protocol (UDP) protocol. User Datagram Protocol (UDP) is one of the core protocols of the Internet protocol suite. Using UDP, programs on networked computers can send short messages sometimes known as datagrams (using Datagram Sockets) to one another. UDP is sometimes called the Universal Datagram Protocol or Unreliable Datagram Protocol. UDP does not guarantee reliability or ordering in the way that TCP does. Datagrams may arrive out of order, appear duplicated, or go missing without notice. Avoiding the overhead of checking whether every packet actually arrived makes UDP faster and more efficient, at least for applications that do not need guaranteed delivery. Time-sensitive applications often use UDP because dropped packets are preferable to delayed packets. UDP's stateless nature is also useful for servers that answer small queries from huge numbers of clients. Unlike TCP, UDP supports packet broadcast (sending to all on local network) and multicasting (send to all subscribers).

The Udp object is part of the Network Component. Overview of all Network Component objects:

DnsServer & DnsRecord - Ftp & FtpFile - Http - Icmp - IPtoCountry - Msn - Ntp - Radius - Rsh - Scp - SFtp - Ssh - SnmpManager - SnmpTrapManager - SnmpMibBrowser - Tcp - Tftp - TraceRoute - Udp - Xen - Wake-on-LAN - Xen (Citrix)


Udp Sample code

VBScript UDP client/server sample: CLIENT.VBS

   ' Create a socket instance
   Set objUdp       = CreateObject ( "ActiveXperts.Udp" )
   Set objConstants = CreateObject ( "ActiveXperts.ASConstants" )

   objUdp.Open "localhost", 1500, True  ' Listen for connection on port 1500
   WScript.Echo "StartListening, result: " & objUdp.LastError
   If objUdp.LastError <> 0 Then
     WScript.Quit
   End If

   Do While str <> "Quit"
     str = objUdp.ReceiveString
      
     If( objUdp.LastError = 0 And str <> "" ) Then
       WScript.Echo "ReceiveString: " & str
     End If
     objUdp.Sleep 100
   Loop

   objUdp.Disconnect

VBScript UDP client/server sample: SERVER.VBS

   ' Create a socket instance
   Set objUdp       = CreateObject ( "ActiveXperts.Udp" )
   Set objConstants = CreateObject ( "ActiveXperts.ASConstants" )

   ' Make a connection to port 1500 on remote server
   objUdp.Open "127.0.0.1", 1500, False
   WScript.Echo "Connect, result: " & objTcp.LastError 
   If objUdp.LastError <> 0	 Then
     WScript.Quit
   End If

   objUdp.SendString "Hello, world!"
   WScript.Echo "SendString, result: " & objUdp.LastError

   objUdp.SendString "Quit"
   WScript.Echo "SendString, result: " & objUdp.LastError

   ' And finally, disconnect
   objUdp.Close 

On ftp.activexperts-labs.com, you can find a lot of Network Component samples. These samples are also part of the Network Component installation.

Visit ftp.activexperts-labs.com