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
240 kFx(kStatus) kSocket_Write(kSocket socket, const void* buffer, kSize size, kSize* written);
241
257 kFx(kStatus) kSocket_WriteTo(kSocket socket, kIpAddress address, k32u port, const void* buffer, kSize size);
258
269 kFx(kStatus) kSocket_SetEvents(kSocket socket, kSocketEvent events);
270
278 kFx(kSocketEvent) kSocket_Events(kSocket socket);
279
290 kFx(kStatus) kSocket_SetBlocking(kSocket socket, kBool isBlocking);
291
300 kFx(kStatus) kSocket_SetWriteBuffer(kSocket socket, kSize size);
301
310 kFx(kStatus) kSocket_SetReadBuffer(kSocket socket, kSize size);
311
322 kFx(kStatus) kSocket_SetWriteTimeout(kSocket socket, k64u timeout);
323
334 kFx(kStatus) kSocket_SetReadTimeout(kSocket socket, k64u timeout);
335
348 kFx(kStatus) kSocket_EnableBroadcast(kSocket socket, kBool broadcast);
349
364 kFx(kStatus) kSocket_EnableReuseAddress(kSocket socket, kBool reuse);
365
377 kFx(kStatus) kSocket_SetNoDelay(kSocket socket, kBool noDelay);
378
391 kFx(kStatus) kSocket_SetLingerTime(kSocket socket, k64u lingerTime);
392
404 kFx(kStatus) kSocket_BindToDevice(kSocket socket, const kChar* interfaceName);
405
414 kFx(kStatus) kSocket_LocalEndPoint(kSocket socket, kIpEndPoint* endPoint);
415
424 kFx(kStatus) kSocket_RemoteEndPoint(kSocket socket, kIpEndPoint* endPoint);
425
433 kFx(kStatus) kSocket_Status(kSocket socket);
434
446 kFx(kSize) kSocket_Handle(kSocket socket);
447
448 #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_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.