Platforms to show: All Mac Windows Linux Cross-Platform

/Network/Bonjour/Bonjour Console
Function:
Required plugins for this example: MBS Util Plugin, MBS Network Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Network/Bonjour/Bonjour Console
This example is the version from Fri, 13th Oct 2016.
Project "Bonjour Console.xojo_binary_project"
Class App Inherits ConsoleApplication
EventHandler Function Run(args() as String) As Integer print "This application does registering a service, browse and lookup this service." print "Press control-C to quit." b=new MyBonjourBrowseMBS r=new MyBonjourRegisterMBS l=new MyBonjourLookupMBS if b.Available then print "Bonjour is available." else print "No Bonjour found!" Return 1 end if Register // wait 2 seconds and give sockets, threads and timers time for i as integer=0 to 20 DelayMBS 0.1 DoEvents next Browse // give sockets, threads and timers time do DelayMBS 0.1 DoEvents loop End EventHandler
Protected Sub Browse() if b.Browse(0,"_echo._tcp","local.") then print "Browse started successfull." else print "Browse failed." end if End Sub
Sub Lookup(ServiceName as string, domain as string) if app.l.Resolve(app.l.kInterfaceIndexAny, ServiceName,"_echo._tcp.", domain) then print "Lookup started successfull." else print "Lookup failed." end if End Sub
Protected Sub Register() if r.Register(0,0,"MyService","_echo._tcp.", "local.", "", 1111, "") then print "Registering started successfull." else print "Registering failed." end if End Sub
Property Protected b As MyBonjourBrowseMBS
Property Protected l As MyBonjourLookupMBS
Property Protected r As MyBonjourRegisterMBS
End Class
Class MyBonjourBrowseMBS Inherits DNSServiceBrowseMBS
EventHandler Sub ServiceBrowse(Flags as integer, InterfaceIndex as integer, ErrorCode as integer, ServiceName as string, RegType as string, Domain as string) print "ServiceBrowse event." print " Service name: "+ServiceName print " Interface index: "+str(InterfaceIndex) print " Registration Type: "+RegType print " Domain: "+domain print " Flags: "+str(flags) app.lookup ServiceName, domain End EventHandler
End Class
Class MyBonjourLookupMBS Inherits DNSServiceResolveMBS
EventHandler Sub ServiceResolve(flags as integer, InterfaceIndex as integer, ErrorCode as integer, Fullname as string, Hosttarget as string, Port as integer, TxtRecord as string) print "ServiceLookup event." print " Error code: "+str(ErrorCode) print " IP: "+DNSNameToAddressMBS(Hosttarget) print " Port: "+str(port) print " Interface index: "+str(InterfaceIndex) print " Host target: "+Hosttarget print " Fullname: "+Fullname End EventHandler
End Class
Class MyBonjourRegisterMBS Inherits DNSServiceRegisterMBS
EventHandler Sub ServiceRegistration(flags as integer, errorcode as integer, Name as string, RegType as string, Domain as string) print "ServiceRegistration event." print " Errorcode: "+str(errorcode) End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Network Plugin.

The biggest plugin in space...




Links
MBS Xojo Plugins