Socket.h

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.6 $
00022 // $Date: 2005/11/23 23:43:47 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/channel/Socket.h,v $
00024                                                                         
00025 // Written: fmk 11/95
00026 // Revised:
00027 //
00028 // Purpose: This file contains all the includes needed by files
00029 // using the Berkeley socket stuff.
00030 
00031 #ifndef Socket_h
00032 #define Socket_h
00033 
00034 extern "C" {
00035 #include <stdio.h>
00036 #include <stdlib.h>
00037 #include <string.h>
00038 #ifdef _WIN32
00039   #include <winsock2.h>
00040 #else
00041   #include <sys/socket.h>
00042   #include <sys/types.h>
00043   #include <netinet/in.h>
00044   #include <netinet/tcp.h>
00045   #include <arpa/inet.h>
00046   #include <netdb.h>
00047   #include <unistd.h>
00048   #include <strings.h>
00049 #endif
00050 }
00051 
00052 #include <OPS_Stream.h>
00053 #include <bool.h>
00054 
00055 #define MAX_UDP_DATAGRAM 9126
00056 #define MAX_INET_ADDR 28
00057 
00058 #ifdef _WIN32
00059   typedef SOCKET socket_type;
00060   typedef int socklen_type;
00061   #define bzero(s,n) memset((s),0,(n))
00062   #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
00063 #else
00064   typedef int socket_type;
00065   typedef socklen_t socklen_type;
00066 #endif
00067 
00068 inline bool startup_socket()
00069 {
00070   #ifdef _WIN32
00071     WSADATA wsaData;
00072     return WSAStartup(0x0002, &wsaData) == 0;
00073   #else
00074     return true;
00075   #endif
00076 } 
00077 
00078 inline void cleanup_socket()
00079 {
00080   #ifdef _WIN32
00081     WSACleanup();
00082   #endif
00083 }
00084 
00085 #endif 
00086 
00087 

Generated on Mon Oct 23 15:04:56 2006 for OpenSees by doxygen 1.5.0