---
title: "serviceConnectionWithName:rootObject:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsconnection/serviceconnectionwithname:rootobject:"
---

# serviceConnectionWithName:rootObject:

Creates and returns a new connection object representing a vended service on the default system port name server.

## Declaration

```occ
+ (instancetype) serviceConnectionWithName:(NSString *) name rootObject:(id) root;
```

## Parameters

- `name`: The name of the service you want to publish.
- `root`: The object to use as the root object for the published service. This is the object vended by the connection.

## Return Value

Return Value An NSConnection object representing the vended service or nil if there was a problem setting up the connection object.

## Discussion

Discussion This method creates the server-side of a connection object and registers it with the default system port name server. Clients wishing to connect to this service can request a communications port from the same port server and use that port to communicate.

## See Also

### Related Documentation

- [systemDefaultPortNameServer](foundation/nsportnameserver/systemdefaultportnameserver.md)
- [connectionWithRegisteredName:host:](foundation/nsconnection/connectionwithregisteredname:host:.md)

### Vending a Service

- [serviceConnectionWithName:rootObject:usingNameServer:](foundation/nsconnection/serviceconnectionwithname:rootobject:usingnameserver:.md)
- [registerName:](foundation/nsconnection/registername:.md)
- [registerName:withNameServer:](foundation/nsconnection/registername:withnameserver:.md)
- [rootObject](foundation/nsconnection/rootobject-c.property.md)
