home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- // DIVE Laboratories, Inc.
- // Copyright(c) 1995
- // All rights reserved.
- // FILE: winsock.hpp
- //
- // DESCRIPTION
- // This file provides functions prototypes for the socket classes
- //
- // Author: M. Doucet
- //
- // Modification History:
- // 4/25/95 Created
- // 4/27/95 Change to be unified socket class
- //
- //**********************************************************************/
- #ifndef _WINSOCK_HPP
- #define _WINSOCK_HPP
-
- #ifdef AMBER_DEBUG_LIB
- #define _DEBUG
- #endif
- #ifdef WIN32
- #include <winsock.h>
- #include "datamsg.hpp"
- #endif
- #ifdef AMBER_DEBUG_LIB
- #undef _DEBUG
- #endif
-
- #include "channel.hpp"
- #include "geometry.hpp"
-
- typedef enum {SERVER, CLIENT} socketTypeEnum;
-
- #define CLASS_COMM 90001
- #define CLASS_GEOMETRY 90002
- #define CLASS_CHANNEL 90003
-
- #define DIR_SHUTDOWN 95001
- #define DIR_SHUTDOWNOK 95002
- #define DIR_POSITION 95003
- #define DIR_ORIENTATION 95004
- #define DIR_PQ 95005
-
- class socketClass {
-
- private:
- int socketBufSize, hostPort;
- char hostName[80];
- socketTypeEnum socketType;
- static int winsockInit;
-
- public:
-
- unsigned int fd, connectedFd[5];
- sockaddr_in serverAddr, clientAddr;
- int isOpened[5], nConnected;
-
- int isOpen(int connection=0);
- void sClose();
- void sClose(int connection);
- void sOpen();
- int dataStatus(int connection=0);
- int numConnected();
- void sendData(dataMsgClass *msg, int connection=0);
- void sendRaw(char *buf, int size, int connection=0);
- int recvData(dataMsgClass *msg, int connection=0);
- int recvRaw(char *buf, int size, int connection=0);
-
- void sendVpP(channelClass *pt, int connection=0);
- void sendVpQ(channelClass *pt, int connection=0);
- void sendVpPQ(channelClass *pt, int connection=0);
-
- void sendGeoP(geometryClass *pt, int connection=0);
- void sendGeoQ(geometryClass *pt, int connection=0);
- void sendGeoPQ(geometryClass *pt, int connection=0);
-
- socketClass(socketTypeEnum socketIs,
- int port=5005,
- char *host = "nitro0",
- int bufSize=16384);
- ~socketClass();
-
- };
-
- #endif
-
-