MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
sock.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbc/sock.h,v 1.9 2017/01/12 14:43:43 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #ifndef SOCK_H
33 #define SOCK_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38 
39 #ifndef HAVE_SOCKLEN_T
40 typedef int socklen_t;
41 #endif /* HAVE_SOCKLEN_T */
42 
43 extern int
44 mbdyn_make_inet_socket(struct sockaddr_in *name, const char *hostname,
45  unsigned short int port, int dobind, int *perror);
46 
47 extern int
48 mbdyn_make_inet_socket_type(struct sockaddr_in *name, const char *hostname,
49  unsigned short int port, int socket_type, int dobind, int *perror);
50 
51 extern int
52 mbdyn_make_named_socket(struct sockaddr_un *name, const char *path,
53  int dobind, int *perror);
54 
55 extern int
56 mbdyn_make_named_socket_type(struct sockaddr_un *name, const char *path,
57  int socket_type, int dobind, int *perror);
58 
59 /* These have been erased from FreeBSD's headers, so we have to
60  * work around with this ugly hack. This is not exactly the same,
61  * but it seems to work.
62  * I chose this place for the definitions, since there are different
63  * files using these macros and so we just need to define them once.
64  */
65 #ifndef IPPORT_USERRESERVED
66 #define IPPORT_USERRESERVED IPPORT_RESERVED
67 #endif /* ! IPPORT_USERRESERVED */
68 #ifndef MSG_NOSIGNAL
69 #define MSG_NOSIGNAL SO_NOSIGPIPE
70 #endif /* ! MSG_NOSIGNAL */
71 
72 /* MBDyn's default socket type is tcp (SOCK_STREAM) (not udp, SOCK_DGRAM) */
73 #define MBDYN_DEFAULT_SOCKET_TYPE SOCK_STREAM
74 
75 #ifdef __cplusplus
76 }
77 #endif /* __cplusplus */
78 
79 #endif /* SOCK_H */
int mbdyn_make_named_socket_type(struct sockaddr_un *name, const char *path, int socket_type, int dobind, int *perror)
int mbdyn_make_inet_socket(struct sockaddr_in *name, const char *hostname, unsigned short int port, int dobind, int *perror)
int mbdyn_make_inet_socket_type(struct sockaddr_in *name, const char *hostname, unsigned short int port, int socket_type, int dobind, int *perror)
int mbdyn_make_named_socket(struct sockaddr_un *name, const char *path, int dobind, int *perror)
int socklen_t
Definition: sock.h:40
unsigned short int port
Definition: autopilot.c:143
const char * path
Definition: autopilot.c:141