ArmNN
 20.02
armnnUtils::Sockets Namespace Reference

Functions

bool Initialize ()
 Performs any required one-time setup. More...
 
int Close (Socket s)
 
bool SetNonBlocking (Socket s)
 
long Write (Socket s, const void *buf, size_t len)
 
long Read (Socket s, void *buf, size_t len)
 
int Ioctl (Socket s, unsigned long int cmd, void *arg)
 
int Poll (PollFd *fds, nfds_t numFds, int timeout)
 
armnnUtils::Sockets::Socket Accept (Socket s, sockaddr *addr, socklen_t *addrlen, int flags)
 

Function Documentation

◆ Accept()

Socket Accept ( Socket  s,
sockaddr *  addr,
socklen_t *  addrlen,
int  flags 
)

Definition at line 91 of file NetworkSockets.cpp.

Referenced by GatordMockService::BlockForOneClient().

92 {
93 #if defined(__unix__)
94  return accept4(s, addr, addrlen, flags);
95 #elif defined(_MSC_VER)
96  return accept(s, addr, reinterpret_cast<int*>(addrlen));
97 #endif
98 }

◆ Close()

int Close ( Socket  s)

Definition at line 28 of file NetworkSockets.cpp.

Referenced by SocketProfilingConnection::Close(), FileOnlyProfilingConnection::FileOnlyProfilingConnection(), GatordMockService::LaunchReceivingThread(), and GatordMockService::~GatordMockService().

29 {
30 #if defined(__unix__)
31  return close(s);
32 #elif defined(_MSC_VER)
33  return closesocket(s);
34 #endif
35 }

◆ Initialize()

bool Initialize ( )

Performs any required one-time setup.

Definition at line 18 of file NetworkSockets.cpp.

Referenced by GatordMockService::OpenListeningSocket(), and SocketProfilingConnection::SocketProfilingConnection().

19 {
20 #if defined(__unix__)
21  return true;
22 #elif defined(_MSC_VER)
23  WSADATA wsaData;
24  return WSAStartup(MAKEWORD(2, 2), &wsaData) == 0;
25 #endif
26 }

◆ Ioctl()

int Ioctl ( Socket  s,
unsigned long int  cmd,
void *  arg 
)

Definition at line 69 of file NetworkSockets.cpp.

Referenced by SocketProfilingConnection::ReadPacket(), and GatordMockService::WaitCommand().

70 {
71 #if defined(__ANDROID__)
72  return ioctl(s, static_cast<int>(cmd), arg);
73 #elif defined(__unix__)
74  return ioctl(s, cmd, arg);
75 #elif defined(_MSC_VER)
76  return ioctlsocket(s, cmd, static_cast<u_long*>(arg));
77 #endif
78 }

◆ Poll()

int Poll ( PollFd *  fds,
nfds_t  numFds,
int  timeout 
)

Definition at line 81 of file NetworkSockets.cpp.

Referenced by SocketProfilingConnection::ReadPacket(), and GatordMockService::WaitCommand().

82 {
83 #if defined(__unix__)
84  return poll(fds, numFds, timeout);
85 #elif defined(_MSC_VER)
86  return WSAPoll(fds, numFds, timeout);
87 #endif
88 }

◆ Read()

long Read ( Socket  s,
void *  buf,
size_t  len 
)

Definition at line 60 of file NetworkSockets.cpp.

Referenced by SocketProfilingConnection::ReadPacket(), GatordMockService::WaitCommand(), and GatordMockService::WaitForStreamMetaData().

61 {
62 #if defined(__unix__)
63  return read(s, buf, len);
64 #elif defined(_MSC_VER)
65  return recv(s, static_cast<char*>(buf), len, 0);
66 #endif
67 }

◆ SetNonBlocking()

bool SetNonBlocking ( Socket  s)

Definition at line 38 of file NetworkSockets.cpp.

Referenced by GatordMockService::LaunchReceivingThread(), and SocketProfilingConnection::SocketProfilingConnection().

39 {
40 #if defined(__unix__)
41  const int currentFlags = fcntl(s, F_GETFL);
42  return fcntl(s, F_SETFL, currentFlags | O_NONBLOCK) == 0;
43 #elif defined(_MSC_VER)
44  u_long mode = 1;
45  return ioctlsocket(s, FIONBIO, &mode) == 0;
46 #endif
47 }

◆ Write()

long Write ( Socket  s,
const void *  buf,
size_t  len 
)

Definition at line 50 of file NetworkSockets.cpp.

Referenced by InferenceTestImage::GetSizeInBytes(), GatordMockService::WaitCommand(), and SocketProfilingConnection::WritePacket().

51 {
52 #if defined(__unix__)
53  return write(s, buf, len);
54 #elif defined(_MSC_VER)
55  return send(s, static_cast<const char*>(buf), len, 0);
56 #endif
57 }