/****************************************************************************** * * (c) Copyright 1998, University of Karlstad. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Please report any bugs you find in this code or any improvements to: * * Hans Hedbom, Dept. of Computer Science, * University of Karlstad, Sweden. * * Phone: +46 54 838157 * E-mail: Hans.Hedbom@hks.se * * ============================================================================ * * FILE: * * sockets.h [ the Data Communication I course programming project ] * * AUTHORS: * * Jonny Wiederholm * E-mail: fr7wied@cse.hks.se or * jonnwied@hks.se * * Per-Ola Gustafsson * E-mail: fr7gust@cse.hks.se * * CREATION DATE: * * Jan, 06, 1998 * * DESCRIPTION: * * Includes constants, types and declarations of functions needed to create * and connect sockets in the example implementation of the Data Communication * I course programming project. * * MODIFICATIONS: Date Changes * ---------------------------------------------------------------------------- * */ #ifndef _SOCKETS_H /* Avoid multiple copies of this file. */ #define _SOCKETS_H #ifdef __cplusplus /* Make this file possible to use in C++ code. */ extern "C" { #endif /****************************************************************************** * INCLUDE FILES */ #include "systems.h" #include "udefs.h" /****************************************************************************** * DEFINE CONSTANTS */ #if defined (_AIX) || defined (__linux__) /* Communication semantics. */ #define SOCK_STREAM 1 /* Stream socket. */ #elif defined (sun) #define SOCK_STREAM 2 #endif /* Communication domains. */ #define AF_UNIX 1 /* Local to host (pipes, portals). */ #define AF_INET 2 /* Internetwork: UDP, TCP, etc. */ /****************************************************************************** * DEFINE TYPES */ #if defined (__linux__) || defined (sun) /* Structure used by kernel to store most addresses. */ struct sockaddr { unsigned short int sa_family; /* Address family AF_xxx. */ char sa_data[14]; /* 14 bytes of protocol address. */ }; #elif defined (_AIX) struct sockaddr { unsigned char sa_len; /* Total length. */ unsigned char sa_family; /* Address family AF_xxx. */ char sa_data[14]; /* 14 bytes of protocol address. */ }; #endif /* defined (__linux__) || defined (sun) */ /***************************************************************************** * DECLARE FUNCTIONS */ /* See function definitions for documentation. */ extern int CreateSocket __P((int domain, int type, int protocol)); extern int BindSocket __P((int sockfd, struct sockaddr *name, int namelen)); extern int ConnectSocket __P((int sockfd, struct sockaddr *name, int namelen)); extern int ListenforConnection __P((int sockfd, int limit)); extern int AcceptConnection __P((int sockfd)); /****************************************************************************** * END */ #ifdef __cplusplus } #endif #endif /* _SOCKETS_H */