---
name: "shevek_socket"
section: "3"
platform: "linux"
package: "libshevek-doc"
version: "1.4-1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/shevek_socket"
---

# shevek\_socket(3)

Use a unix-domain, tcp or avahi network connection with shevek::fd.

## NAME

shevek::socket -

Use a unix-domain, tcp or avahi network connection with **shevek::fd**.

## SYNOPSIS

`#include <socket.hh>`

Inherits **shevek::fd**.

Inherited by **shevek::telnet**.

### Public Types

typedef sigc::signal0\< void \> **disconnect\_t**\
 *Disconnect signal type.*  typedef sigc::slot0\< void \> **listen\_t**\
 *New connection callback type.*

### Public Member Functions

void **listen\_unix** (std::string const &**file**, **listen\_t** cb, unsigned queue=10)\
 *Listen for new connections on a UNIX socket. Use listen instead.*  void **listen\_tcp** (std::string const &service, **listen\_t** cb, unsigned queue=10)\
 *Listen for new connections on a TCP socket. Use listen instead.*  void **listen\_avahi** (std::string const &service, Glib::ustring const &protocol, Glib::ustring const &name, **listen\_t** cb, unsigned queue=10)\
 *Listen for new connections on a TCP socket, and register it with avahi. Use listen instead.*  void **listen** (std::string const &port, **listen\_t** cb, unsigned queue=10)\
 *Listen for new connections.*  void **connect\_unix** (std::string const &unix\_name)\
 *Connect to a UNIX socket. Use connect instead.*  void **connect\_tcp** (std::string const &host, std::string const &service)\
 *Connect to a TCP socket. Use connect instead.*  void **connect\_avahi** (**avahi::browser::owner** const &target, **avahi::browser::details** const &details=**avahi::browser::details**())\
 *Connect to an avahi TCP socket. Use connect instead.*  void **connect** (std::string const &port)\
 *Connect to a socket.*  void **accept** (Glib::RefPtr\< **socket** \> sock)\
 *Accept a connection (only allowed on a listening socket).*  std::string **get\_peer\_info** (bool numeric=false) const \
 *Get information about the other side of a connection.*  std::string **get\_own\_info** (bool numeric=false) const \
 *Get info about our side of the connection.*  **disconnect\_t** **signal\_disconnect** ()\
 *Schedule a function to be called when the socket is disconnected.*  void **disconnect** ()\
 *Disconnect the socket without reconnecting.*

### Static Public Member Functions

static Glib::RefPtr\< **socket** \> **create** (Glib::RefPtr\< Glib::MainContext \> main=Glib::MainContext::get\_default())\
 *Create a new socket.*

### Protected Member Functions

**socket** (Glib::RefPtr\< Glib::MainContext \> main)\
 *Constructor.*  virtual **~socket** ()\
 *Destructor.*

## Detailed Description

Use a unix-domain, tcp or avahi network connection with **shevek::fd**.

## Member Function Documentation

### void shevek::socket::connect (std::string const &port)

Connect to a socket. This is the preferred function to use. Format: UNIX domain sockets: anything with at least one / in it. TCP: hostname:port, where the hostname and colon may be omitted, and the port may be a service or number. Avahi: name\|protocol, where name is the application name, and protocol the connection type.

### void shevek::socket::listen (std::string const &port, listen\_tcb, unsignedqueue = `10`)

Listen for new connections. This is the preferred function to use. Format: UNIX domain sockets: anything with at least one / in it. TCP services: the name. TCP port numbers: the number. For TCP, appending \|name\|protocol, where name is the application name and protocol the connection type.

## Author

Generated automatically by Doxygen for libshevek from the source code.
