Zen API

- Home
- Topics
- Types
- Files

All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kSocket.h
Go to the documentation of this file.
1
10 #ifndef K_API_SOCKET_H
11 #define K_API_SOCKET_H
12
13 #include <kApi/Io/kNetwork.h>
14
15 kBeginHeader()
16
17
23 typedef k32s kSocketType;
24
26 #define kSOCKET_TYPE_TCP (0)
27 #define kSOCKET_TYPE_UDP (1)
28
35 typedef k32s kSocketEvent;
36
38 #define kSOCKET_EVENT_READ (1)
39 #define kSOCKET_EVENT_WRITE (2)
40 #define kSOCKET_EVENT_EXCEPT (4)
41
49 //typedef kObject kSocket; --forward-declared in kApiDef.x.h
50
66 kFx(kStatus) kSocket_WaitAny(const kSocket* sockets, kSize count, k64u timeout);
67
80 kFx(kStatus) kSocket_Construct(kSocket* socket, kIpVersion ipVersion, kSocketType socketType, kAlloc allocator);
81
91 kFx(kStatus) kSocket_Bind(kSocket socket, kIpAddress address, k32u port);
92
105 kFx(kStatus) kSocket_Connect(kSocket socket, kIpAddress address, k32u port, k64u timeout);
106
115 kFx(kStatus) kSocket_Listen(kSocket socket, kSize backlog);
116
126 kFx(kStatus) kSocket_Accept(kSocket socket, kSocket* connection, kAlloc allocator);
127
142 kFx(kStatus) kSocket_Wait(kSocket socket, k64u timeout);
143
161 kFx(kStatus) kSocket_Read(kSocket socket, void* buffer, kSize size, kSize* read);
162
178 kFx(kStatus) kSocket_ReadFrom(kSocket socket, kIpEndPoint *endPoint, void* buffer, kSize size, kSize* read);
179
196 kFx(kStatus) kSocket_Write(kSocket socket, const void* buffer, kSize size, kSize* written);
197
213 kFx(kStatus) kSocket_WriteTo(kSocket socket, kIpAddress address, k32u port, const void* buffer, kSize size);
214
225 kFx(kStatus) kSocket_SetEvents(kSocket socket, kSocketEvent events);
226
234 kFx(kSocketEvent) kSocket_Events(kSocket socket);
235
246 kFx(kStatus) kSocket_SetBlocking(kSocket socket, kBool isBlocking);
247
256 kFx(kStatus) kSocket_SetWriteBuffer(kSocket socket, kSize size);
257
266 kFx(kStatus) kSocket_SetReadBuffer(kSocket socket, kSize size);
267
278 kFx(kStatus) kSocket_SetWriteTimeout(kSocket socket, k64u timeout);
279
290 kFx(kStatus) kSocket_SetReadTimeout(kSocket socket, k64u timeout);
291
304 kFx(kStatus) kSocket_EnableBroadcast(kSocket socket, kBool broadcast);
305
320 kFx(kStatus) kSocket_EnableReuseAddress(kSocket socket, kBool reuse);
321
333 kFx(kStatus) kSocket_SetNoDelay(kSocket socket, kBool noDelay);
334
347 kFx(kStatus) kSocket_SetLingerTime(kSocket socket, k64u lingerTime);
348
360 kFx(kStatus) kSocket_BindToDevice(kSocket socket, const kChar* interfaceName);
361
370 kFx(kStatus) kSocket_LocalEndPoint(kSocket socket, kIpEndPoint* endPoint);
371
380 kFx(kStatus) kSocket_RemoteEndPoint(kSocket socket, kIpEndPoint* endPoint);
381
389 kFx(kStatus) kSocket_Status(kSocket socket);
390
391 kEndHeader()
392
393 #include <kApi/Io/kSocket.x.h>
394
395 #endif
kSocket::kSocket_Write
kStatus kSocket_Write(kSocket socket, const void *buffer, kSize size, kSize *written)
Writes one or more bytes.
k32u
Represents a 32-bit unsigned integer.
kSocket::kSocket_Accept
kStatus kSocket_Accept(kSocket socket, kSocket *connection, kAlloc allocator)
Blocks until an incoming connection request is accepted.
kSocket::kSocket_BindToDevice
kStatus kSocket_BindToDevice(kSocket socket, const kChar *interfaceName)
Binds the socket to a specific network interface.
kSocket::kSocket_SetWriteTimeout
kStatus kSocket_SetWriteTimeout(kSocket socket, k64u timeout)
Sets the timeout duration for blocking write operations.
kSocket::kSocket_Events
kSocketEvent kSocket_Events(kSocket socket)
Gets the events detected during the most recent wait operation.
k64u
Represents a 64-bit unsigned integer.
kSocket::kSocket_SetEvents
kStatus kSocket_SetEvents(kSocket socket, kSocketEvent events)
Sets the event types that a socket will wait on.
kIpVersion
Represents an Internet Protocol version.
kSocket::kSocket_ReadFrom
kStatus kSocket_ReadFrom(kSocket socket, kIpEndPoint *endPoint, void *buffer, kSize size, kSize *read)
Reads a datagram.
kSize
Represents an unsigned integer that can store a pointer address.
kAlloc
Abstract base class for memory allocator types.
kSocketEvent
Represents a set of socket event types.
kSocket::kSocket_LocalEndPoint
kStatus kSocket_LocalEndPoint(kSocket socket, kIpEndPoint *endPoint)
Returns the local end point for a bound socket.
kSocket::kSocket_SetNoDelay
kStatus kSocket_SetNoDelay(kSocket socket, kBool noDelay)
Can be used to disable the Nagle algorithm.
kIpAddress
Represents an IP address.
Definition: kNetwork.h:38
kChar
Represents a single unit (byte) in a UTF-8 character.
kSocket::kSocket_SetBlocking
kStatus kSocket_SetBlocking(kSocket socket, kBool isBlocking)
Determines whether the socket will block on read/write requests.
kSocket::kSocket_WaitAny
kStatus kSocket_WaitAny(const kSocket *sockets, kSize count, k64u timeout)
Waits until an event occurs on one or more sockets.
kSocket::kSocket_EnableReuseAddress
kStatus kSocket_EnableReuseAddress(kSocket socket, kBool reuse)
Enables or disables reuse of a local end point within a short period of time.
kSocket::kSocket_RemoteEndPoint
kStatus kSocket_RemoteEndPoint(kSocket socket, kIpEndPoint *endPoint)
Returns the remote end point for a connected socket.
kSocket::kSocket_Listen
kStatus kSocket_Listen(kSocket socket, kSize backlog)
Places the socket into a listening state, to monitor for incoming connection requests.
kSocket::kSocket_WriteTo
kStatus kSocket_WriteTo(kSocket socket, kIpAddress address, k32u port, const void *buffer, kSize size)
Sends a datagram.
kSocket::kSocket_Wait
kStatus kSocket_Wait(kSocket socket, k64u timeout)
Waits for a socket event.
kSocket::kSocket_Construct
kStatus kSocket_Construct(kSocket *socket, kIpVersion ipVersion, kSocketType socketType, kAlloc allocator)
Constructs a kSocket object.
kSocketType
Represents the underlying type of a socket.
kSocket::kSocket_SetLingerTime
kStatus kSocket_SetLingerTime(kSocket socket, k64u lingerTime)
Specifies the duration that a TCP connection can remain open when the socket is closed in order to en...
kSocket::kSocket_Connect
kStatus kSocket_Connect(kSocket socket, kIpAddress address, k32u port, k64u timeout)
Connects the socket to a remote end point.
k32s
Represents a 32-bit signed integer.
kSocket::kSocket_Read
kStatus kSocket_Read(kSocket socket, void *buffer, kSize size, kSize *read)
Reads one or more bytes.
kSocket::kSocket_Bind
kStatus kSocket_Bind(kSocket socket, kIpAddress address, k32u port)
Binds the socket to a local IP address and/or port.
kSocket::kSocket_Status
kStatus kSocket_Status(kSocket socket)
Reports any internal errors that will prevent success of future communication attempts.
kSocket::kSocket_SetWriteBuffer
kStatus kSocket_SetWriteBuffer(kSocket socket, kSize size)
Sets the size of the write buffer used by the underlying operating system.
kSocket::kSocket_SetReadTimeout
kStatus kSocket_SetReadTimeout(kSocket socket, k64u timeout)
Sets the timeout duration for blocking read operations.
kNetwork.h
IP networking definitions.
kStatus
Represents an error code.
kSocket::kSocket_EnableBroadcast
kStatus kSocket_EnableBroadcast(kSocket socket, kBool broadcast)
Enables or disables datagram broadcasting.
kSocket::kSocket_SetReadBuffer
kStatus kSocket_SetReadBuffer(kSocket socket, kSize size)
Sets the size of the read buffer used by the underlying operating system.
kIpEndPoint
Represents an IP end point (address, port).
Definition: kNetwork.h:170
kSocket
Represents a network socket.
kBool
Represents a boolean value.