Contents

CFNetServiceCreate(_:_:_:_:_:)

Creates an instance of a Network Service object.

Declaration

func CFNetServiceCreate(_ alloc: CFAllocator?, _ domain: CFString, _ serviceType: CFString, _ name: CFString, _ port: Int32) -> Unmanaged<CFNetService>

Parameters

  • alloc:

    The allocator to use to allocate memory for the new object. Pass NULL or Kcfallocatordefault to use the current default allocator.

  • domain:

    The domain in which the CFNetService is to be registered; cannot be NULL. Call Cfnetservicebrowsercreate(_:_:_:) and Cfnetservicebrowsersearchfordomains(_:_:_:) to get the registration domain.

  • name:

    A unique name if the instance will be used to register a service. The name will become part of the instance name in the DNS records that will be created when the service is registered. If the instance will be used to resolve a service, the name should be the name of the machine or service that will be resolved.

  • port:

    Local IP port, in host byte order, on which this service accepts connections. Pass zero to get placeholder service. With a placeholder service, the service will not be discovered by browsing, but a name conflict will occur if another client tries to register the same name. Most applications do not need to use placeholder service.

Return Value

A new net service object, or NULL if the instance could not be created. Ownership follows the The Create Rule.

Discussion

If the service depends on information in DNS TXT records, call CFNetServiceSetProtocolSpecificInformation.

If the CFNetService is to run in asynchronous mode, call CFNetServiceSetClient(_:_:_:) to prepare the service for running in asynchronous mode. Then call CFNetServiceScheduleWithRunLoop(_:_:_:) to schedule the service on a run loop. Then call CFNetServiceRegister to make the service available.

If the CFNetService is to run in synchronous mode, call CFNetServiceRegister.

To terminate a service that is running in asynchronous mode, call CFNetServiceCancel(_:) and CFNetServiceUnscheduleFromRunLoop(_:_:_:).

To terminate a service that is running in synchronous mode, call CFNetServiceCancel(_:).

Special Considerations

This function is thread safe.

See Also

Network Services