Platforms to show: All Mac Windows Linux Cross-Platform
/MacOSX/Bonjour/Find computer
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/Bonjour/Find computer
This example is the version from Fri, 25th Feb 2010.
Notes: Last modified: Fri, 25th Feb 2010
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/Bonjour/Find computer
This example is the version from Fri, 25th Feb 2010.
Notes: Last modified: Fri, 25th Feb 2010
Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance
// Properties
Protected Dim lookup(-1) As MyLookup
Protected Dim browser(-1) As MyBrowser
// Event implementations
Sub Open()
StartBrowse "_ftp._tcp","FTP Server"
StartBrowse "_afpovertcp._tcp","Apple File Sharing"
StartBrowse "_nfs._tcp","Network File System"
StartBrowse "_http._tcp","Webserver"
StartBrowse "_printer._tcp","Printer"
StartBrowse "_ichat._tcp","iChat (old)"
StartBrowse "_presence._tcp","iChat"
StartBrowse "_daap._tcp","iTunes"
StartBrowse "_dpap._tcp","iPhoto"
StartBrowse "_ipp._tcp","Intenet Printing Protocol"
StartBrowse "_pdl-datastream._tcp","PDL Data Stream"
StartBrowse "_distcc._tcp","XCode"
StartBrowse "_xserveraid._tcp","XServe RAID"
End Sub
// Methods
Protected Sub StartBrowse(typ as string, reason as string)
dim b as MyBrowser
b=new MyBrowser
if b.Browse(0,typ,"") then
b.Reason=reason
browser.Append b
else
List.AddRow "Failed to init browser for "+typ
end if
End Sub
Sub StartLookup(name as string, type as string, domain as string, reason as string)
dim b as MyLookup
ClearLookups
b=new MyLookup
if b.Lookup(0,name,type,domain) then
b.Reason=reason
b.name=name
lookup.Append b
end if
End Sub
Sub ClearLookups()
dim l as MyLookup
dim i,c as integer
c=UBound(lookup)
for i=c downto 0
if lookup(i).done then
lookup.Remove i
end if
next
End Sub
End Class
Class App
Inherits Application
End Class
Class MyBrowser
Inherits Object
// Properties
Dim reason As string
// Event implementations
Sub ServiceBrowse(Flags as integer, InterfaceIndex as integer, ErrorCode as integer, ServiceName as string, RegType as string, Domain as string)
const kDNSServiceFlagsAdd=2
dim f as integer
f=BitwiseAnd(Flags, kDNSServiceFlagsAdd)
if f<>0 then
// added
Window1.StartLookup ServiceName,RegType,domain,reason
else
// removed
Window1.List.AddRow ServiceName
Window1.List.Cell(Window1.List.LastIndex,1)="gone"
Window1.List.Cell(Window1.List.LastIndex,2)=""
Window1.List.Cell(Window1.List.LastIndex,3)=reason
end if
End Sub
End Class
Class MyLookup
Inherits Object
// Properties
Dim reason As string
Dim done As boolean
Dim name As string
// Event implementations
Sub ServiceLookup(flags as integer, InterfaceIndex as integer, ErrorCode as integer, Fullname as string, Hosttarget as string, Port as integer, TxtRecord as string)
dim l as listbox
l=Window1.List
l.addrow name
l.Cell(l.LastIndex,1)=DNSNameToAddressMBS(Hosttarget)+":"+str(port)
l.Cell(l.LastIndex,2)=Hosttarget
l.Cell(l.LastIndex,3)=reason
End Sub
End Class
See also:
Links
MBS Realbasic PDF Plugins - Pfarrgemeinde St. Arnulf Nickenich