S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_sockets_internal_ctx.h File Reference
#include <stdbool.h>
#include "sopc_async_queue.h"
#include "sopc_event_handler.h"
#include "sopc_mutexes.h"
#include "sopc_raw_sockets.h"
#include "sopc_sockets_api.h"
#include "sopc_toolkit_config_constants.h"

Go to the source code of this file.

Data Structures

struct  SOPC_InternalSocket
 

Typedefs

typedef struct SOPC_InternalSocket SOPC_InternalSocket
 

Enumerations

enum  SOPC_Socket_State {
  SOCKET_STATE_CLOSED = 0 , SOCKET_STATE_CONNECTING , SOCKET_STATE_CONNECTED , SOCKET_STATE_LISTENING ,
  SOCKET_STATE_ACCEPTED
}
 

Functions

void SOPC_SocketsInternalContext_Initialize (void)
 Initialize the array of sockets.
 
void SOPC_SocketsInternalContext_Clear (void)
 Clear the array of sockets.
 
SOPC_InternalSocketSOPC_SocketsInternalContext_GetFreeSocket (bool isListener)
 Returns an unused socket from the array of sockets or NULL if none available In case socket is not a listnener, the write buffer queue is initialized. Note: caller must lock the mutex before calling it.
 
void SOPC_SocketsInternalContext_CloseSocket (uint32_t socketIdx)
 Close the socket and set it as not used anymore.
 
void SOPC_Sockets_Emit (SOPC_Sockets_OutputEvent event, uint32_t eltId, uintptr_t params, uintptr_t auxParam)
 Emits an output event to the recorded output event handler socketsEventHandler.
 
SOPC_ReturnStatus SOPC_Sockets_EnqueueInputEvent (SOPC_Sockets_InputEvent socketEvent, uint32_t id, uintptr_t params, uintptr_t auxParam)
 Enqueues an input event to the queue of events managed by the socket event manager.
 
SOPC_ReturnStatus SOPC_Sockets_DequeueAndDispatchInputEvent (void)
 Dequeues an input event of the queue of events and call the event dispatcher of the socket event manager. If an event was dispatched SOPC_STATUS_OK is returned, if the queue is empty SOPC_STATUS_WOULD_BLOCK is returned.
 

Variables

SOPC_InternalSocket socketsArray [SOPC_MAX_SOCKETS]
 Array containing all sockets that can be used.
 
SOPC_EventHandlersocketsEventHandler
 
uint32_t maxBufferSize
 

Typedef Documentation

◆ SOPC_InternalSocket

typedef struct SOPC_InternalSocket SOPC_InternalSocket

Enumeration Type Documentation

◆ SOPC_Socket_State

Enumerator
SOCKET_STATE_CLOSED 
SOCKET_STATE_CONNECTING 

Client connect waiting for write event && SO_ERROR to be verified on event to confirm connection accepted

SOCKET_STATE_CONNECTED 

Client: write event received after connect / Server: connection accepted (socket level

  • SC connection level)
SOCKET_STATE_LISTENING 

Server: listening socket

SOCKET_STATE_ACCEPTED 

Server: accepted socket connection at socket level only (missing SC connection level)

Function Documentation

◆ SOPC_SocketsInternalContext_Initialize()

void SOPC_SocketsInternalContext_Initialize ( void )

Initialize the array of sockets.

◆ SOPC_SocketsInternalContext_Clear()

void SOPC_SocketsInternalContext_Clear ( void )

Clear the array of sockets.

◆ SOPC_SocketsInternalContext_GetFreeSocket()

SOPC_InternalSocket * SOPC_SocketsInternalContext_GetFreeSocket ( bool isListener)

Returns an unused socket from the array of sockets or NULL if none available In case socket is not a listnener, the write buffer queue is initialized. Note: caller must lock the mutex before calling it.

◆ SOPC_SocketsInternalContext_CloseSocket()

void SOPC_SocketsInternalContext_CloseSocket ( uint32_t socketIdx)

Close the socket and set it as not used anymore.

◆ SOPC_Sockets_Emit()

void SOPC_Sockets_Emit ( SOPC_Sockets_OutputEvent event,
uint32_t eltId,
uintptr_t params,
uintptr_t auxParam )

Emits an output event to the recorded output event handler socketsEventHandler.

◆ SOPC_Sockets_EnqueueInputEvent()

SOPC_ReturnStatus SOPC_Sockets_EnqueueInputEvent ( SOPC_Sockets_InputEvent socketEvent,
uint32_t id,
uintptr_t params,
uintptr_t auxParam )

Enqueues an input event to the queue of events managed by the socket event manager.

◆ SOPC_Sockets_DequeueAndDispatchInputEvent()

SOPC_ReturnStatus SOPC_Sockets_DequeueAndDispatchInputEvent ( void )

Dequeues an input event of the queue of events and call the event dispatcher of the socket event manager. If an event was dispatched SOPC_STATUS_OK is returned, if the queue is empty SOPC_STATUS_WOULD_BLOCK is returned.

Variable Documentation

◆ socketsArray

SOPC_InternalSocket socketsArray[SOPC_MAX_SOCKETS]
extern

Array containing all sockets that can be used.

◆ socketsEventHandler

SOPC_EventHandler* socketsEventHandler
extern

◆ maxBufferSize

uint32_t maxBufferSize
extern