home *** CD-ROM | disk | FTP | other *** search
/ VRML Tools for 3D Cyberspace / VRML_Tools_For_3D_Cyberspace.iso / amber / include / winsock.hpp < prev   
Encoding:
C/C++ Source or Header  |  1996-07-01  |  2.1 KB  |  89 lines

  1. /**********************************************************************
  2. //  DIVE Laboratories, Inc.
  3. //  Copyright(c) 1995
  4. //  All rights reserved.
  5. //  FILE:   winsock.hpp
  6. //
  7. //  DESCRIPTION
  8. //  This file provides functions prototypes for the socket classes
  9. //
  10. //  Author: M. Doucet
  11. //
  12. //  Modification History:
  13. //  4/25/95    Created
  14. //  4/27/95        Change to be unified socket class
  15. //
  16. //**********************************************************************/
  17. #ifndef _WINSOCK_HPP
  18. #define _WINSOCK_HPP
  19.  
  20. #ifdef AMBER_DEBUG_LIB
  21. #define _DEBUG
  22. #endif
  23. #ifdef WIN32
  24. #include <winsock.h>        
  25. #include "datamsg.hpp"
  26. #endif
  27. #ifdef AMBER_DEBUG_LIB
  28. #undef _DEBUG
  29. #endif
  30.  
  31. #include "channel.hpp"
  32. #include "geometry.hpp"
  33.  
  34. typedef enum {SERVER, CLIENT} socketTypeEnum;
  35.  
  36. #define CLASS_COMM       90001
  37. #define CLASS_GEOMETRY  90002
  38. #define CLASS_CHANNEL   90003
  39.  
  40. #define DIR_SHUTDOWN     95001
  41. #define DIR_SHUTDOWNOK     95002
  42. #define DIR_POSITION     95003
  43. #define DIR_ORIENTATION 95004
  44. #define DIR_PQ          95005
  45.  
  46. class socketClass {
  47.  
  48. private:
  49.     int socketBufSize, hostPort;
  50.     char hostName[80];
  51.     socketTypeEnum socketType;
  52.     static int winsockInit;
  53.  
  54. public:
  55.  
  56.     unsigned int fd, connectedFd[5];
  57.     sockaddr_in serverAddr, clientAddr;
  58.     int isOpened[5], nConnected;
  59.  
  60.     int  isOpen(int connection=0);
  61.     void sClose();
  62.     void sClose(int connection);
  63.     void sOpen();
  64.     int  dataStatus(int connection=0);
  65.     int  numConnected();
  66.     void sendData(dataMsgClass *msg, int connection=0);
  67.     void sendRaw(char *buf, int size, int connection=0);
  68.     int  recvData(dataMsgClass *msg, int connection=0);
  69.     int  recvRaw(char *buf, int size, int connection=0);
  70.  
  71.     void sendVpP(channelClass *pt, int connection=0);
  72.     void sendVpQ(channelClass *pt, int connection=0);
  73.     void sendVpPQ(channelClass *pt, int connection=0);
  74.  
  75.     void sendGeoP(geometryClass *pt, int connection=0);
  76.     void sendGeoQ(geometryClass *pt, int connection=0);
  77.     void sendGeoPQ(geometryClass *pt, int connection=0);
  78.  
  79.     socketClass(socketTypeEnum socketIs,
  80.                     int port=5005,
  81.                     char *host = "nitro0", 
  82.                     int bufSize=16384);
  83.     ~socketClass();
  84.  
  85. };
  86.  
  87. #endif 
  88.  
  89.