3 * Copyright (C) 2004 Simone Piccardi
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /***************************************************************
22 * Routines for socket address resolution.
29 ***************************************************************/
30 #include <sys/types.h>
32 #include <stdio.h> /* standard I/O functions */
33 #include <signal.h> /* signal handling declarations */
37 #include <sys/socket.h> /* socket function and declaration */
38 #include <netdb.h> /* resolver functions */
42 /* *************************************************************************
44 * Functions for socket address automatic resolution
46 * ************************************************************************* */
49 * Create and attach a SysV shared memory segment to the current process.
51 * First call get a shared memory segment with KEY key access and size SIZE,
52 * by creating it with R/W privilege for the user (this is the meaning of
53 * the ored flags). The function return an identifier shmid used for any
54 * further reference to the shared memory segment.
55 * Second call attach the shared memory segment to this process and return a
56 * pointer to it (of void * type).
57 * Then initialize shared memory to the given value
61 * Return: the IP address of the host in a sockaddr structure
63 int tcp_addr(char * address, char * service, struct sockaddr * sa)
65 struct addrinfo hints = {
66 ai_flag: AI_CANONNAME,
68 ai_socktype: SOCK_STREAM,