libiec61850
1.2.0
|
Typedefs | |
typedef struct sServerSocket * | ServerSocket |
typedef struct sSocket * | Socket |
typedef struct sHandleSet * | HandleSet |
Functions | |
HandleSet | Handleset_new (void) |
Create a new connection handle set (HandleSet) More... | |
void | Handleset_addSocket (HandleSet self, const Socket sock) |
add a socket to an existing handle set More... | |
int | Handleset_waitReady (HandleSet self, unsigned int timeoutMs) |
wait for a socket to become ready More... | |
void | Handleset_destroy (HandleSet self) |
destroy the HandleSet instance More... | |
ServerSocket | TcpServerSocket_create (const char *address, int port) |
Create a new TcpServerSocket instance. More... | |
void | ServerSocket_listen (ServerSocket self) |
Socket | ServerSocket_accept (ServerSocket self) |
accept a new incoming connection (non-blocking) More... | |
void | ServerSocket_setBacklog (ServerSocket self, int backlog) |
set the maximum number of pending connection in the queue More... | |
void | ServerSocket_destroy (ServerSocket self) |
destroy a server socket instance More... | |
Socket | TcpSocket_create (void) |
create a TCP client socket More... | |
void | Socket_setConnectTimeout (Socket self, uint32_t timeoutInMs) |
set the timeout to establish a new connection More... | |
bool | Socket_connect (Socket self, const char *address, int port) |
connect to a server More... | |
int | Socket_read (Socket self, uint8_t *buf, int size) |
read from socket to local buffer (non-blocking) More... | |
int | Socket_write (Socket self, uint8_t *buf, int size) |
send a message through the socket More... | |
char * | Socket_getPeerAddress (Socket self) |
Get the address of the peer application (IP address and port number) More... | |
void | Socket_destroy (Socket self) |
destroy a socket (close the socket if a connection is established) More... | |
Thread and Socket abstraction layer. This functions have to be implemented to port libIEC61850 to a new hardware/OS platform.
typedef struct sHandleSet* HandleSet |
Opaque reference for a set of server and socket handles
typedef struct sServerSocket* ServerSocket |
Opaque reference for a server socket instance
typedef struct sSocket* Socket |
Opaque reference for a client or connection socket instance
add a socket to an existing handle set
self | the HandleSet instance |
sock | the socket to add |
void Handleset_destroy | ( | HandleSet | self | ) |
destroy the HandleSet instance
self | the HandleSet instance to destroy |
HandleSet Handleset_new | ( | void | ) |
Create a new connection handle set (HandleSet)
int Handleset_waitReady | ( | HandleSet | self, |
unsigned int | timeoutMs | ||
) |
wait for a socket to become ready
This function is corresponding to the BSD socket select function. The function will return after timeoutMs
ms if no data is pending.
self | the HandleSet instance |
timeout | in milliseconds (ms) |
Socket ServerSocket_accept | ( | ServerSocket | self | ) |
accept a new incoming connection (non-blocking)
This function shall accept a new incoming connection. It is non-blocking and has to return NULL if no new connection is pending.
Implementation of this function is MANDATORY if server functionality is required.
NOTE: The behaviour of this function changed with version 0.8!
self | server socket instance |
void ServerSocket_destroy | ( | ServerSocket | self | ) |
destroy a server socket instance
Free all resources allocated by this server socket instance.
Implementation of this function is MANDATORY if server functionality is required.
self | server socket instance |
void ServerSocket_listen | ( | ServerSocket | self | ) |
void ServerSocket_setBacklog | ( | ServerSocket | self, |
int | backlog | ||
) |
set the maximum number of pending connection in the queue
Implementation of this function is OPTIONAL.
self | the server socket instance |
backlog | the number of pending connections in the queue |
bool Socket_connect | ( | Socket | self, |
const char * | address, | ||
int | port | ||
) |
connect to a server
Connect to a server application identified by the address and port parameter.
The "address" parameter may either be a hostname or an IP address. The IP address has to be provided as a C string (e.g. "10.0.2.1").
Implementation of this function is MANDATORY if client functionality is required.
NOTE: return type changed from int to bool with version 0.8
self | the client socket instance |
address | the IP address or hostname as C string |
port | the TCP port of the application to connect to |
void Socket_destroy | ( | Socket | self | ) |
destroy a socket (close the socket if a connection is established)
This function shall close the connection (if one is established) and free all resources allocated by the socket.
Implementation of this function is MANDATORY
self | the client, connection or server socket instance |
char* Socket_getPeerAddress | ( | Socket | self | ) |
Get the address of the peer application (IP address and port number)
The peer address has to be returned as
Implementation of this function is MANDATORY
self | the client, connection or server socket instance |
int Socket_read | ( | Socket | self, |
uint8_t * | buf, | ||
int | size | ||
) |
read from socket to local buffer (non-blocking)
The function shall return immediately if no data is available. In this case the function returns 0. If an error happens the function shall return -1.
Implementation of this function is MANDATORY
NOTE: The behaviour of this function changed with version 0.8!
self | the client, connection or server socket instance |
buf | the buffer where the read bytes are copied to |
size | the maximum number of bytes to read (size of the provided buffer) |
void Socket_setConnectTimeout | ( | Socket | self, |
uint32_t | timeoutInMs | ||
) |
set the timeout to establish a new connection
self | the client socket instance |
timeoutInMs | the timeout in ms |
int Socket_write | ( | Socket | self, |
uint8_t * | buf, | ||
int | size | ||
) |
send a message through the socket
Implementation of this function is MANDATORY
self | client, connection or server socket instance |
ServerSocket TcpServerSocket_create | ( | const char * | address, |
int | port | ||
) |
Create a new TcpServerSocket instance.
Implementation of this function is MANDATORY if server functionality is required.
address | ip address or hostname to listen on |
port | the TCP port to listen on |
Socket TcpSocket_create | ( | void | ) |
create a TCP client socket
Implementation of this function is MANDATORY if client functionality is required.