msousa@0: /* msousa@0: * Copyright (c) 2016 Mario de Sousa (msousa@fe.up.pt) msousa@0: * msousa@0: * This file is part of the Modbus library for Beremiz and matiec. msousa@0: * msousa@0: * This Modbus library is free software: you can redistribute it and/or modify msousa@0: * it under the terms of the GNU Lesser General Public License as published by msousa@0: * the Free Software Foundation, either version 3 of the License, or msousa@0: * (at your option) any later version. msousa@0: * msousa@0: * This program is distributed in the hope that it will be useful, but msousa@0: * WITHOUT ANY WARRANTY; without even the implied warranty of msousa@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser msousa@0: * General Public License for more details. msousa@0: * msousa@0: * You should have received a copy of the GNU Lesser General Public License msousa@0: * along with this Modbus library. If not, see . msousa@0: * msousa@0: * This code is made available on the understanding that it will not be msousa@0: * used in safety-critical situations without a full and competent review. msousa@0: */ msousa@0: msousa@0: msousa@0: #ifndef SIN_UTIL_H msousa@0: #define SIN_UTIL_H msousa@0: msousa@0: msousa@0: #include msousa@0: #include msousa@0: #include msousa@0: #include msousa@0: msousa@0: msousa@0: msousa@0: /* Create a socket for the IP protocol family, and connect to remote host. */ msousa@0: int sin_connsock(const char *host, const char *service, const char *protocol); msousa@0: msousa@0: /* Create a socket for the IP protocol family, and bind to local host's port. */ msousa@0: int sin_bindsock(const char *host, const char *service, const char *protocol); msousa@0: msousa@0: /* Initialize a in_addr structure */ msousa@0: int sin_initaddr(struct sockaddr_in *sin, msousa@0: const char *host, int allow_null_host, // 1 => allow host NULL, "" or "*" -> INADDR_ANY msousa@0: const char *service, int allow_null_serv, // 1 => allow serivce NULL or "" -> port = 0 msousa@0: const char *protocol); msousa@0: #endif