## nng_pub_open

Create pub socket.

### Synopsis

```c
#include <nng/nng.h>
#include <nng/protocol/pubsub0/pub.h>

int nng_pub0_open(nng_socket *s);
int nng_pub0_open_raw(nng_socket *s);
```

### Description

The `nng_pub0_open` function creates a xref:../proto/pub.adoc[_PUB_] version 0 xref:../index.adoc[socket] and returns it at the location pointed to by _s_.

The `nng_pub0_open_raw` function creates a _PUB_ version 0 socket in xref:../sock/raw.adoc[raw_mode] and returns it at the location pointed to by _s_.

### Return Values

These functions return 0 on success, and non-zero otherwise.

### Errors

[horizontal]
`NNG_ENOMEM`:: Insufficient memory is available.
`NNG_ENOTSUP`:: The protocol is not supported.

### See Also

xref:../proto/pub.adoc[Publisher Protocol (_PUB_)],
xref:../proto/sub.adoc[Subscriber Protocol (_SUB_)]
