libIEC61850  0.8.4
Open-source IEC 61850 MMS/GOOSE server and client library
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hal_socket.h
Go to the documentation of this file.
1 /*
2  * socket_hal.h
3  *
4  * Copyright 2013, 2014 Michael Zillgith
5  *
6  * This file is part of libIEC61850.
7  *
8  * libIEC61850 is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * libIEC61850 is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * See COPYING file for the complete license text.
22  */
23 
24 #ifndef SOCKET_HAL_H_
25 #define SOCKET_HAL_H_
26 
27 #include <stdint.h>
28 #include <stdbool.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
49 typedef struct sServerSocket* ServerSocket;
50 
52 typedef struct sSocket* Socket;
53 
55 typedef struct sHandleSet* HandleSet;
56 
62 HandleSet
63 Handleset_new(void);
64 
71 void
72 Handleset_addSocket(HandleSet self, const Socket sock);
73 
74 
87 int
88 Handleset_waitReady(HandleSet self, unsigned int timeoutMs);
89 
95 void
96 Handleset_destroy(HandleSet self);
97 
108 ServerSocket
109 TcpServerSocket_create(const char* address, int port);
110 
111 
112 void
113 ServerSocket_listen(ServerSocket self);
114 
129 Socket
130 ServerSocket_accept(ServerSocket self);
131 
132 
142 void
143 ServerSocket_setBacklog(ServerSocket self, int backlog);
144 
154 void
155 ServerSocket_destroy(ServerSocket self);
156 
164 Socket
165 TcpSocket_create(void);
166 
173 void
174 Socket_setConnectTimeout(Socket self, uint32_t timeoutInMs);
175 
194 bool
195 Socket_connect(Socket self, const char* address, int port);
196 
213 int
214 Socket_read(Socket self, uint8_t* buf, int size);
215 
225 int
226 Socket_write(Socket self, uint8_t* buf, int size);
227 
239 char*
240 Socket_getPeerAddress(Socket self);
241 
252 void
253 Socket_destroy(Socket self);
254 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif /* SOCKET_HAL_H_ */