sin_util.h
changeset 0 ae252e0fd9b8
equal deleted inserted replaced
-1:000000000000 0:ae252e0fd9b8
       
     1 /*
       
     2  * Copyright (c) 2016 Mario de Sousa (msousa@fe.up.pt)
       
     3  *
       
     4  * This file is part of the Modbus library for Beremiz and matiec.
       
     5  *
       
     6  * This Modbus library is free software: you can redistribute it and/or modify
       
     7  * it under the terms of the GNU Lesser General Public License as published by
       
     8  * the Free Software Foundation, either version 3 of the License, or
       
     9  * (at your option) any later version.
       
    10  *
       
    11  * This program is distributed in the hope that it will be useful, but
       
    12  * WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
       
    14  * General Public License for more details.
       
    15  *
       
    16  * You should have received a copy of the GNU Lesser General Public License
       
    17  * along with this Modbus library.  If not, see <http://www.gnu.org/licenses/>.
       
    18  *
       
    19  * This code is made available on the understanding that it will not be
       
    20  * used in safety-critical situations without a full and competent review.
       
    21  */
       
    22 
       
    23 
       
    24 #ifndef SIN_UTIL_H
       
    25 #define SIN_UTIL_H
       
    26 
       
    27 
       
    28 #include <sys/types.h>
       
    29 #include <sys/socket.h>
       
    30 #include <netinet/in.h>
       
    31 #include <arpa/inet.h>
       
    32 
       
    33 
       
    34 
       
    35 /* Create a socket for the IP protocol family, and connect to remote host. */
       
    36 int sin_connsock(const char *host, const char *service, const char *protocol);
       
    37 
       
    38 /* Create a socket for the IP protocol family, and bind to local host's port. */
       
    39 int sin_bindsock(const char *host, const char *service, const char *protocol);
       
    40 
       
    41 /* Initialize a in_addr structure */
       
    42 int sin_initaddr(struct sockaddr_in *sin,
       
    43                  const char *host,    int allow_null_host, // 1 => allow host NULL, "" or "*" -> INADDR_ANY
       
    44                  const char *service, int allow_null_serv, // 1 => allow serivce NULL or ""   -> port = 0
       
    45                  const char *protocol);
       
    46 #endif