Go to the documentation of this file.
74 struct XsSocketInterface;
100 typedef unsigned __int64
XSOCKET;
112 #define XSSOCKET_INITIALIZER { NULL }
115 #define XSSOCKET_INFINITE_TIMEOUT -1
202 inline XSOCKET nativeDescriptor()
const
216 inline int read(
XsByteArray& buffer,
int timeout = 0)
231 inline int read(
void* dest,
XsSize size,
int timeout = 0)
247 inline int readFrom(
XsByteArray& buffer,
XsString* hostname = NULL, uint16_t* port = NULL,
int timeout = 0)
264 inline int readFrom(
void* dest,
XsSize size,
XsString* hostname = NULL, uint16_t* port = NULL,
int timeout = 0)
279 return write(buffer.data(), buffer.size());
308 return writeTo(buffer.data(), buffer.size(), hostname, port);
340 int select(
int mstimeout,
int* canRead,
int* canWrite)
359 inline void*
operator new (size_t)
363 throw std::bad_alloc();
368 inline void operator delete (
void* p) noexcept
455 bool isUsable()
const
474 int getLastSystemError()
const
487 int broadcast(
const void*
data,
XsSize size, uint16_t port)
497 bool enableBroadcasts(
bool enable)
XSTYPES_DLL_API int XsSocket_write(XsSocket *thisPtr, const void *buffer, XsSize size)
Write data to the socket.
XSTYPES_DLL_API int XsSocket_writeTo(XsSocket *thisPtr, const void *buffer, XsSize size, const XsString *hostname, uint16_t port)
Write data to the socket to the host indicated by hostname, port.
XSTYPES_DLL_API XsResultValue XsSocket_connect(XsSocket *thisPtr, const XsString *host, uint16_t port)
Connect to hostame on port.
@ NLP_IPVX
any IP address family
IpProtocol
the protocol on top of IP
A list of uint8_t values.
@ IP_TCP
The TCP/IP protocol.
XSTYPES_DLL_API XsSocket * XsSocket_accept(XsSocket *thisPtr, int mstimeout)
Accept an incoming connection.
@ XSO_ReuseAddress
Allow bind to reuse a local port (using different local addresses)
XSTYPES_DLL_API void XsSocket_destroy(XsSocket *thisPtr)
Destroy the given socket.
#define XSSOCKET_INFINITE_TIMEOUT
XSTYPES_DLL_API void XsSocket_flush(XsSocket *thisPtr)
Flush the incoming data.
struct XsSocketPrivate * d
NetworkLayerProtocol
The network layer protocol, or IP address family.
XsResultValue
Xsens result values.
XSTYPES_DLL_API XsSocket * XsSocket_allocate()
Dynamically allocate an XsSocket.
A platform independent socket implementation.
int XsSocket_select(XsSocket *thisPtr, int mstimeout, int *canRead, int *canWrite)
Wait for read or write for mstimeout milliseconds on socket thisPtr.
XSTYPES_DLL_API int XsSocket_broadcast(XsSocket *thisPtr, const void *buffer, XsSize size, uint16_t port)
Broadcast data over the socket to the port indicated by port.
XSTYPES_DLL_API int XsSocket_getLastSystemError(const XsSocket *thisPtr)
Return the system error code of the last socket operation.
size_t XsSize
XsSize must be unsigned number!
XsResultValue XsSocket_close(XsSocket *thisPtr)
Close a socket.
XSTYPES_DLL_API void XsSocket_getRemoteAddress(const XsSocket *thisPtr, XsString *address)
Get the numeric IP address of remote host of this socket.
@ IP_UDP
The UDP/IP protocol.
XSTYPES_DLL_API void XsSocket_create(XsSocket *thisPtr, enum NetworkLayerProtocol ip, enum IpProtocol protocol)
Create socket thisPtr for IP version ip with protocol protocol.
XSTYPES_DLL_API int XsSocket_readFrom(XsSocket *thisPtr, void *dest, XsSize size, XsString *hostname, uint16_t *port, int timeout)
Read size data into dest.
XSTYPES_DLL_API XSOCKET XsSocket_nativeDescriptor(XsSocket const *thisPtr)
Return the native file descriptor.
@ NLP_IPV4
IPv4 address family.
void XsSocket_createFromFileDescriptor(XsSocket *thisPtr, int sockfd, XsDataFlags flags)
Create a socket from a native file descriptor.
XSTYPES_DLL_API int XsSocket_isUsable(const XsSocket *thisPtr)
Return non-zero if the socket is usable for reading and writing data.
XSTYPES_DLL_API XsResultValue XsSocket_listen(XsSocket *thisPtr, int maxPending)
Start listening for incoming connections on this socket.
XSTYPES_DLL_API void XsSocket_free(XsSocket *thisPtr)
Free a socket returned from XsSocket_accept() or XsSocket_allocate()
XSTYPES_DLL_API XsResultValue XsSocket_bind(XsSocket *thisPtr, const XsString *hostname, uint16_t port)
Bind to the hostname and port combination.
@ NLP_IPV6
IPv6 address family.
XsDataFlags
These flags define the behaviour of data contained by Xsens data structures.
XSTYPES_DLL_API int XsSocket_read2ByteArray(XsSocket *thisPtr, XsByteArray *dest, int timeout)
Read size data into dest.
@ XSO_ReusePort
Allow bind to reuse the exact local address.
int XsSocket_enableBroadcasts(XsSocket *thisPtr, int enable)
Enable sending and receiving broadcasts on this socket.
A 0-terminated managed string of characters.
XSTYPES_DLL_API int XsSocket_read(XsSocket *thisPtr, void *dest, XsSize size, int timeout)
Read size data into dest.
XSTYPES_DLL_API int XsSocket_readFrom2ByteArray(XsSocket *thisPtr, XsByteArray *dest, XsString *hostname, uint16_t *port, int timeout)
Read size data into dest.
XsResultValue XsSocket_setSocketOption(XsSocket *thisPtr, enum XsSocketOption option, void *valuePtr, int valueSize)
Changes the value of a socket option.