summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/libraries/nacl_io/socket/unix_node.h
blob: 881261a356da1e94ac4850565746d403810498b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBRARIES_NACL_IO_SOCKET_UNIX_NODE_H_
#define LIBRARIES_NACL_IO_SOCKET_UNIX_NODE_H_

#include "nacl_io/ossocket.h"
#ifdef PROVIDES_SOCKET_API

#include "nacl_io/node.h"
#include "nacl_io/socket/socket_node.h"
#include "nacl_io/socket/unix_event_emitter.h"

namespace nacl_io {

class UnixNode : public SocketNode {
 public:
  UnixNode(Filesystem* filesystem, int type);
  UnixNode(Filesystem* filesystem, const UnixNode& peer);

  virtual EventEmitter* GetEventEmitter();

 protected:
  virtual Error Recv_Locked(void* buffer,
                            size_t len,
                            PP_Resource* out_addr,
                            int* out_len);
  virtual Error Send_Locked(const void* buffer,
                            size_t len,
                            PP_Resource addr,
                            int* out_len);
  virtual Error RecvFrom(const HandleAttr& attr,
                         void* buf,
                         size_t len,
                         int flags,
                         struct sockaddr* src_addr,
                         socklen_t* addrlen,
                         int* out_len);
  virtual Error Send(const HandleAttr& attr,
                     const void* buf,
                     size_t len,
                     int flags,
                     int* out_len);
  virtual Error SendTo(const HandleAttr& attr,
                       const void* buf,
                       size_t len,
                       int flags,
                       const struct sockaddr* dest_addr,
                       socklen_t addrlen,
                       int* out_len);

 private:
  ScopedUnixEventEmitter emitter_;
};

}  // namespace nacl_io

#endif  // PROVIDES_SOCKET_API
#endif  // LIBRARIES_NACL_IO_SOCKET_UNIX_NODE_H_