lib60870-C  2.3.2
C source code library for the IEC 60870-5-101/104 protocols
Typedefs | Enumerations | Functions
hal_socket.h File Reference

Abstraction layer TCP/IP sockets Has to be implemented for CS 104 TCP/IP. More...

#include "hal_base.h"
Include dependency graph for hal_socket.h:

Go to the source code of this file.

Typedefs

typedef struct sServerSocket * ServerSocket
 
typedef struct sUdpSocket * UdpSocket
 
typedef struct sSocket * Socket
 
typedef struct sHandleSet * HandleSet
 

Enumerations

enum  SocketState { SOCKET_STATE_CONNECTING = 0 , SOCKET_STATE_FAILED = 1 , SOCKET_STATE_CONNECTED = 2 }
 

Functions

PAL_API HandleSet Handleset_new (void)
 Create a new connection handle set (HandleSet) More...
 
PAL_API void Handleset_reset (HandleSet self)
 Reset the handle set for reuse.
 
PAL_API void Handleset_addSocket (HandleSet self, const Socket sock)
 add a socket to an existing handle set More...
 
void Handleset_removeSocket (HandleSet self, const Socket sock)
 remove a socket from an existing handle set
 
PAL_API int Handleset_waitReady (HandleSet self, unsigned int timeoutMs)
 wait for a socket to become ready More...
 
PAL_API void Handleset_destroy (HandleSet self)
 destroy the HandleSet instance More...
 
PAL_API ServerSocket TcpServerSocket_create (const char *address, int port)
 Create a new TcpServerSocket instance. More...
 
PAL_API UdpSocket UdpSocket_create (void)
 
PAL_API bool UdpSocket_bind (UdpSocket self, const char *address, int port)
 
PAL_API bool UdpSocket_sendTo (UdpSocket self, const char *address, int port, uint8_t *msg, int msgSize)
 
PAL_API int UdpSocket_receiveFrom (UdpSocket self, char *address, int maxAddrSize, uint8_t *msg, int msgSize)
 Receive data from UDP socket (store data and (optionally) the IP address of the sender. More...
 
PAL_API void ServerSocket_listen (ServerSocket self)
 
PAL_API Socket ServerSocket_accept (ServerSocket self)
 accept a new incoming connection (non-blocking) More...
 
PAL_API void Socket_activateTcpKeepAlive (Socket self, int idleTime, int interval, int count)
 active TCP keep alive for socket and set keep alive parameters More...
 
PAL_API void ServerSocket_setBacklog (ServerSocket self, int backlog)
 set the maximum number of pending connections in the queue More...
 
PAL_API void ServerSocket_destroy (ServerSocket self)
 destroy a server socket instance More...
 
PAL_API Socket TcpSocket_create (void)
 create a TCP client socket More...
 
PAL_API void Socket_setConnectTimeout (Socket self, uint32_t timeoutInMs)
 set the timeout to establish a new connection More...
 
PAL_API bool Socket_bind (Socket self, const char *srcAddress, int srcPort)
 bind a socket to a particular IP address and port (for TcpSocket) More...
 
PAL_API bool Socket_connect (Socket self, const char *address, int port)
 connect to a server More...
 
PAL_API bool Socket_connectAsync (Socket self, const char *address, int port)
 
PAL_API SocketState Socket_checkAsyncConnectState (Socket self)
 
PAL_API int Socket_read (Socket self, uint8_t *buf, int size)
 read from socket to local buffer (non-blocking) More...
 
PAL_API int Socket_write (Socket self, uint8_t *buf, int size)
 send a message through the socket More...
 
PAL_API char * Socket_getLocalAddress (Socket self)
 
PAL_API char * Socket_getPeerAddress (Socket self)
 Get the address of the peer application (IP address and port number) More...
 
PAL_API char * Socket_getPeerAddressStatic (Socket self, char *peerAddressString)
 Get the address of the peer application (IP address and port number) More...
 
PAL_API void Socket_destroy (Socket self)
 destroy a socket (close the socket if a connection is established) More...
 

Detailed Description

Abstraction layer TCP/IP sockets Has to be implemented for CS 104 TCP/IP.