S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_raw_sockets.h
Go to the documentation of this file.
1/*
2 * Licensed to Systerel under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work
4 * for additional information regarding copyright ownership.
5 * Systerel licenses this file to you under the Apache
6 * License, Version 2.0 (the "License"); you may not use this
7 * file except in compliance with the License. You may obtain
8 * a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
26#ifndef SOPC_RAW_SOCKETS_H_
27#define SOPC_RAW_SOCKETS_H_
28
29#include <stdbool.h>
30#include <stdint.h>
31#include "sopc_enums.h"
32
39#define SOPC_INVALID_SOCKET NULL
40
46
52
58
75 unsigned int firstProbeDelay,
76 unsigned int interval,
77 unsigned int counter);
78
89
94
99
112SOPC_ReturnStatus SOPC_Socket_AddrInfo_Get(const char* hostname, const char* port, SOPC_Socket_AddressInfo** addrs);
113
123
133
142
152
162
177
186
193
207 bool setReuseAddr,
208 bool setNonBlocking,
209 SOPC_Socket* sock);
210
222
235SOPC_ReturnStatus SOPC_Socket_Accept(SOPC_Socket listeningSock, bool setNonBlocking, SOPC_Socket* acceptedSock);
236
250
264
278
285
291
299
315
330 SOPC_SocketSet* writeSet,
331 SOPC_SocketSet* exceptSet,
332 uint32_t waitMs);
333
348SOPC_ReturnStatus SOPC_Socket_Write(SOPC_Socket sock, const uint8_t* data, uint32_t count, uint32_t* sentBytes);
349
364SOPC_ReturnStatus SOPC_Socket_Read(SOPC_Socket sock, uint8_t* data, uint32_t dataSize, uint32_t* readCount);
365
377
384
385#endif /* SOPC_RAW_SOCKETS_H_ */
enum _SOPC_ReturnStatus SOPC_ReturnStatus
Common enumerations for S2OPC.
SOPC_ReturnStatus SOPC_Socket_Connect(SOPC_Socket sock, SOPC_Socket_AddressInfo *addr)
Operation to establish a connection using the given socket and addressing information Connection esta...
SOPC_Socket_AddressInfo * SOPC_Socket_AddrInfo_IterNext(SOPC_Socket_AddressInfo *addr)
Given a socket addressing information element of a linked list, provides the next addressing informat...
bool SOPC_Socket_Network_Initialize(void)
Initialize the network communication allowing to use sockets.
SOPC_Socket_Address * SOPC_Socket_GetPeerAddress(SOPC_Socket sock)
Given a socket get the address information associated to the peer connected to the socket.
SOPC_Socket_Impl * SOPC_Socket
Definition sopc_raw_sockets.h:38
SOPC_Socket_Address * SOPC_Socket_CopyAddress(SOPC_Socket_AddressInfo *addr)
Copy the socket address from a socket address information.
SOPC_ReturnStatus SOPC_Socket_BytesToRead(SOPC_Socket sock, uint32_t *bytesToRead)
Retrieve number of bytes available to read on the socket.
void SOPC_SocketSet_Delete(SOPC_SocketSet **set)
Delete the pointed socket set and set the pointer to NULL.
SOPC_ReturnStatus SOPC_Socket_Read(SOPC_Socket sock, uint8_t *data, uint32_t dataSize, uint32_t *readCount)
Read data through the socket.
void SOPC_SocketAddress_Delete(SOPC_Socket_Address **addr)
Deallocate a socket address obtained with SOPC_Socket_GetPeerAddress or SOPC_Socket_CopyAddress.
bool SOPC_Socket_Network_Clear(void)
Clear the network communication when sockets not used anymore.
SOPC_ReturnStatus SOPC_Socket_ConnectToLocal(SOPC_Socket from, SOPC_Socket to)
Operation to establish a connection using the given socket to the given local socket....
SOPC_ReturnStatus SOPC_Socket_Write(SOPC_Socket sock, const uint8_t *data, uint32_t count, uint32_t *sentBytes)
Write data through the socket.
SOPC_ReturnStatus SOPC_Socket_CheckAckConnect(SOPC_Socket sock)
Operation to check connection establishment result on a connecting socket After using SOPC_Socket_Con...
void SOPC_Socket_Clear(SOPC_Socket *sock)
Clear socket state to an invalid socket.
void SOPC_Socket_Close(SOPC_Socket *sock)
Close the socket connection and/or clear the socket.
uint8_t SOPC_Socket_AddrInfo_IsIPV6(const SOPC_Socket_AddressInfo *addr)
Given a socket addressing information element, returns 0 if address is not IPV6 and not 0 value other...
void SOPC_SocketSet_Clear(SOPC_SocketSet *sockSet)
Clear a socket set.
SOPC_ReturnStatus SOPC_Socket_Network_Enable_Keepalive(SOPC_Socket sock, unsigned int firstProbeDelay, unsigned int interval, unsigned int counter)
Activate the keep alive mechanism. According to RFC1122, this mechanism shall be used with care: deac...
SOPC_ReturnStatus SOPC_Socket_Network_Disable_Keepalive(SOPC_Socket sock)
Deactivate the keep alive mechanism.
SOPC_ReturnStatus SOPC_Socket_AddrInfo_Get(const char *hostname, const char *port, SOPC_Socket_AddressInfo **addrs)
Provide a linked list of socket addressing information for establishing TCP connections over IPV4 and...
SOPC_ReturnStatus SOPC_Socket_Listen(SOPC_Socket sock, SOPC_Socket_AddressInfo *addr)
Configure the socket to listen connections using the given addressing information Connection on a lis...
SOPC_ReturnStatus SOPC_Socket_CreateNew(SOPC_Socket_AddressInfo *addr, bool setReuseAddr, bool setNonBlocking, SOPC_Socket *sock)
Create a new socket using the addressing information provided.
bool SOPC_SocketSet_IsPresent(SOPC_Socket sock, SOPC_SocketSet *sockSet)
Returns if a socket is present in the given socket set.
SOPC_ReturnStatus SOPC_Socket_Accept(SOPC_Socket listeningSock, bool setNonBlocking, SOPC_Socket *acceptedSock)
Operation to accept a connection on a listening socket Connection on a listening socket is detected w...
int32_t SOPC_Socket_WaitSocketEvents(SOPC_SocketSet *readSet, SOPC_SocketSet *writeSet, SOPC_SocketSet *exceptSet, uint32_t waitMs)
Wait for events (read, write and exception) on the sockets in the given sets for a given duration....
void SOPC_Socket_AddrInfoDelete(SOPC_Socket_AddressInfo **addrs)
Deallocate a linked list of socket addressing information.
void SOPC_SocketSet_Add(SOPC_Socket sock, SOPC_SocketSet *sockSet)
Add a socket to the given socket set.
SOPC_ReturnStatus SOPC_SocketAddress_GetNameInfo(const SOPC_Socket_Address *addr, char **host, char **service)
Get address information as C strings from the given socket address.
SOPC_SocketSet * SOPC_SocketSet_Create(void)
Create a socket set.
Set of sockets type.
Definition p_sopc_sockets.h:63
fd_set set
Definition p_sopc_sockets.h:65
Socket addressing information for listening or connecting operation type.
Definition p_sopc_sockets.h:46
Socket address information on a connected socket.
Definition p_sopc_sockets.h:55
Socket base type.
Definition p_sopc_sockets.h:36