libIEC61850  0.8.0
Open-source IEC 61850 MMS/GOOSE server and client library
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
socket.h
Go to the documentation of this file.
1 /*
2  * socket.h
3  *
4  * Copyright 2013 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_H_
25 #define SOCKET_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 
64 ServerSocket
65 TcpServerSocket_create(const char* address, int port);
66 
67 
68 void
69 ServerSocket_listen(ServerSocket self);
70 
85 Socket
86 ServerSocket_accept(ServerSocket self);
87 
88 
98 void
99 ServerSocket_setBacklog(ServerSocket self, int backlog);
100 
110 void
111 ServerSocket_destroy(ServerSocket self);
112 
120 Socket
121 TcpSocket_create(void);
122 
141 bool
142 Socket_connect(Socket self, const char* address, int port);
143 
160 int
161 Socket_read(Socket self, uint8_t* buf, int size);
162 
170 int
171 Socket_write(Socket self, uint8_t* buf, int size);
172 
184 char*
185 Socket_getPeerAddress(Socket self);
186 
197 void
198 Socket_destroy(Socket self);
199 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif /* SOCKET_H_ */