15 #if PLATFORM_IS_LINUX || PLATFORM_IS_APPLE 18 #include <sys/socket.h> 19 #include <sys/ioctl.h> 20 #include <arpa/inet.h> 52 addrinfo* result =
NULL;
53 addrinfo hints = addrinfo();
56 hints.ai_protocol = IPPROTO_TCP;
57 hints.ai_flags = AI_PASSIVE;
66 m_socket =
socket(result->ai_family, result->ai_socktype, result->ai_protocol);
83 status =
::bind(
m_socket, result->ai_addr, (
int)result->ai_addrlen);
106 for (
size_t i = 0; i <
m_clients.size(); i++)
116 uint8_t readBuff[8192];
141 for (
size_t i = 0; i <
m_clients.size(); i++)
166 for (
size_t i = 0; i <
m_clients.size(); i++)
170 while (written < dataLength)
187 if (written == dataLength)
virtual void OnClientConnecting(cISTcpServer *server)
NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
NMI_API sint8 listen(SOCKET sock, uint8 backlog)
int ISSocketClose(socket_t &socket)
int ISSocketRead(socket_t socket, uint8_t *data, int dataLength)
size_t count(InputIterator first, InputIterator last, T const &item)
NMI_API sint8 accept(SOCKET sock, struct sockaddr *addr, uint8 *addrlen)
virtual void OnClientConnected(cISTcpServer *server, socket_t socket)
int Open(const string &ipAddress, int port)
int ISSocketCanRead(socket_t socket, int timeoutMilliseconds)
virtual void OnClientConnectFailed(cISTcpServer *server)
void ISSocketFrameworkShutdown()
NMI_API sint8 bind(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen)
NMI_API sint8 setsockopt(SOCKET socket, uint8 u8Level, uint8 option_name, const void *option_value, uint16 u16OptionLen)
int Write(const uint8_t *data, int dataLength)
cISTcpServer(iISTcpServerDelegate *delegate=NULL)
int ISSocketSetBlocking(socket_t socket, bool blocking)
USBInterfaceDescriptor data
void ISSocketFrameworkInitialize()
int ISSocketWrite(socket_t socket, const uint8_t *data, int dataLength)
virtual void OnClientDataReceived(cISTcpServer *server, socket_t socket, uint8_t *data, int dataLength)
iISTcpServerDelegate * m_delegate
vector< socket_t > m_clients
virtual void OnClientDisconnected(cISTcpServer *server, socket_t socket)