---
name: "ACE_SOCK"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_SOCK"
---

# ACE\_SOCK(3)

An abstract class that forms the basis for more specific classes, such as ACE\_SOCK\_Acceptor and ACE\_SOCK\_Stream. Do not instantiate this class.

## NAME

ACE\_SOCK -  An abstract class that forms the basis for more specific classes, such as ACE\_SOCK\_Acceptor and ACE\_SOCK\_Stream. Do not instantiate this class.

## SYNOPSIS

```
#include <ace/SOCK.h>
class ACE_SOCK : public ACE_IPC_SAP
{
  public:
    ~ACE_SOCK (void);
    int set_option (
        int level,
        int option,
        void *optval,
        int optlen
        ) const;
    int get_option (
        int level,
        int option,
        void *optval,
        int *optlen
        ) const;
    int close (void);
    int get_local_addr (ACE_Addr &) const;
    int get_remote_addr (ACE_Addr &) const;
    void dump (void) const;
    ACE_ALLOC_HOOK_DECLARE;
    int open (
        int type,
        int protocol_family,
        int protocol,
        int reuse_addr
        );
    int open (
        int type,
        int protocol_family,
        int protocol,
        ACE_Protocol_Info *protocolinfo,
        ACE_SOCK_GROUP g,
        u_long flags,
        int reuse_addr
        );
  protected:
    ACE_SOCK (
        int type,
        int protocol_family,
        int protocol = 0,
        int reuse_addr = 0
        );
    ACE_SOCK (
        int type,
        int protocol_family,
        int protocol,
        ACE_Protocol_Info *protocolinfo,
        ACE_SOCK_GROUP g,
        u_long flags,
        int reuse_addr
        );
    ACE_SOCK (void);
};
```

## DESCRIPTION

This class provides functions that are common to all of the ACE\_SOCK\_\* classes. ACE\_SOCK provides the ability to get and set socket options, get the local and remote addresses, and close the socket.

## PUBLIC MEMBERS

```
~ACE_SOCK (void);
```

Default ctor/dtor.

```
int set_option (
    int level,
    int option,
    void *optval,
    int optlen
    ) const;
```

Wrapper around the setsockopt system call.

```
int get_option (
    int level,
    int option,
    void *optval,
    int *optlen
    ) const;
```

Wrapper around the getsockopt system call.

```
int close (void);
```

Close down the socket.

```
int get_local_addr (ACE_Addr &) const;
```

Return the local endpoint address in the referenced ACE\_Addr. Returns 0 if successful, else -1.

```
int get_remote_addr (ACE_Addr &) const;
```

Return the address of the remotely connected peer (if there is one), in the referenced ACE\_Addr. Returns 0 if successful, else -1.

```
void dump (void) const;
```

Dump the state of an object.

```
ACE_ALLOC_HOOK_DECLARE;
```

Declare the dynamic allocation hooks.

```
int open (
    int type,
    int protocol_family,
    int protocol,
    int reuse_addr
    );
```

Wrapper around the BSD-style socket system call (no QoS).

```
int open (
    int type,
    int protocol_family,
    int protocol,
    ACE_Protocol_Info *protocolinfo,
    ACE_SOCK_GROUP g,
    u_long flags,
    int reuse_addr
    );
```

Wrapper around the QoS-enabled WSASocket function.

## PROTECTED MEMBERS

```
ACE_SOCK (
    int type,
    int protocol_family,
    int protocol = 0,
    int reuse_addr = 0
    );
```

Constructor with arguments to call the BSD-style socket system call (no QoS).

```
ACE_SOCK (
    int type,
    int protocol_family,
    int protocol,
    ACE_Protocol_Info *protocolinfo,
    ACE_SOCK_GROUP g,
    u_long flags,
    int reuse_addr
    );
```

Constructor with arguments to call the QoS-enabled WSASocket function.

```
ACE_SOCK (void);
```

Default constructor is private to prevent instances of this class from being defined.

## AUTHOR

Doug Schmidt

## LIBRARY

ace
