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
21 typedef k32s kSocketType;
22
24 #define kSOCKET_TYPE_TCP (0)
25 #define kSOCKET_TYPE_UDP (1)
26
33 typedef k32s kSocketEvent;
34
36 #define kSOCKET_EVENT_READ (1)
37 #define kSOCKET_EVENT_WRITE (2)
38 #define kSOCKET_EVENT_EXCEPT (4)
39
41 #include <kApi/Io/kSocket.x.h>
42
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
124 kFx(kStatus) kSocket_BeginConnect(kSocket socket, kIpAddress address, k32u port);
125
135 kFx(kStatus) kSocket_EndConnect(kSocket socket, k64u timeout);
136
145 kFx(kStatus) kSocket_Listen(kSocket socket, kSize backlog);
146
156 kFx(kStatus) kSocket_Accept(kSocket socket, kSocket* connection, kAlloc allocator);
157
170 kFx(kStatus) kSocket_Shutdown(kSocket socket);
171
186 kFx(kStatus) kSocket_Wait(kSocket socket, k64u timeout);
187
205 kFx(kStatus) kSocket_Read(kSocket socket, void* buffer, kSize size, kSize* read);
206
222 kFx(kStatus) kSocket_ReadFrom(kSocket socket, kIpEndPoint *endPoint, void* buffer, kSize size, kSize* read);
223
244 kFx(kStatus) kSocket_ReadFromEx(kSocket socket, kIpEndPoint *endPoint, kSize* interfaceIndex, void* buffer, kSize size, kSize* read);
245
262 kFx(kStatus) kSocket_Write(kSocket socket, const void* buffer, kSize size, kSize* written);
263
279 kFx(kStatus) kSocket_WriteTo(kSocket socket, kIpAddress address, k32u port, const void* buffer, kSize size);
280
291 kFx(kStatus) kSocket_SetEvents(kSocket socket, kSocketEvent events);
292
300 kFx(kSocketEvent) kSocket_Events(kSocket socket);
301
312 kFx(kStatus) kSocket_SetBlocking(kSocket socket, kBool isBlocking);
313
322 kFx(kStatus) kSocket_SetWriteBuffer(kSocket socket, kSize size);
323
332 kFx(kStatus) kSocket_SetReadBuffer(kSocket socket, kSize size);
333
344 kFx(kStatus) kSocket_SetWriteTimeout(kSocket socket, k64u timeout);
345
356 kFx(kStatus) kSocket_SetReadTimeout(kSocket socket, k64u timeout);
357
370 kFx(kStatus) kSocket_EnableBroadcast(kSocket socket, kBool broadcast);
371
386 kFx(kStatus) kSocket_EnableReuseAddress(kSocket socket, kBool reuse);
387
399 kFx(kStatus) kSocket_SetNoDelay(kSocket socket, kBool noDelay);
400
413 kFx(kStatus) kSocket_SetLingerTime(kSocket socket, k64u lingerTime);
414
426 kFx(kStatus) kSocket_EnablePacketInfo(kSocket socket, kBool enabled);
427
439 kFx(kStatus) kSocket_BindToDevice(kSocket socket, const kChar* interfaceName);
440
449 kFx(kStatus) kSocket_LocalEndPoint(kSocket socket, kIpEndPoint* endPoint);
450
459 kFx(kStatus) kSocket_RemoteEndPoint(kSocket socket, kIpEndPoint* endPoint);
460
468 kFx(kStatus) kSocket_Status(kSocket socket);
469
481 kFx(kSize) kSocket_Handle(kSocket socket);
482
483 #endif
kSocket::kSocket_BeginConnect
kStatus kSocket_BeginConnect(kSocket socket, kIpAddress address, k32u port)
Begins connecting the socket to a remote end point.
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_ReadFromEx
kStatus kSocket_ReadFromEx(kSocket socket, kIpEndPoint *endPoint, kSize *interfaceIndex, void *buffer, kSize size, kSize *read)
Reads a datagram and provides information about the destination address and the index of the adapter ...
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_Handle
kSize kSocket_Handle(kSocket socket)
Provides access to the underlying O/S socket handle.
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_Shutdown
kStatus kSocket_Shutdown(kSocket socket)
Begins shutdown of socket communication.
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:36
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:168
kSocket::kSocket_EndConnect
kStatus kSocket_EndConnect(kSocket socket, k64u timeout)
Completes a connection operation that was started with kSocket_BeginConnect.
kSocket
Represents a network socket.
kBool
Represents a boolean value.
kSocket::kSocket_EnablePacketInfo
kStatus kSocket_EnablePacketInfo(kSocket socket, kBool enabled)
Enables or disables interface index information for datagrams.