Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 #ifndef STK_SOCKET_H 00002 #define STK_SOCKET_H 00003 00004 #include "Stk.h" 00005 00006 #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__)) 00007 00008 #include <sys/socket.h> 00009 #include <sys/types.h> 00010 #include <arpa/inet.h> 00011 #include <netdb.h> 00012 #include <unistd.h> 00013 #include <fcntl.h> 00014 #include <netinet/in.h> 00015 #include <netinet/tcp.h> 00016 00017 #elif defined(__OS_WINDOWS__) 00018 00019 #include <winsock.h> 00020 00021 #endif 00022 00023 namespace stk { 00024 00025 /***************************************************/ 00036 /***************************************************/ 00037 00038 class Socket : public Stk 00039 { 00040 public: 00041 00042 enum ProtocolType { 00043 PROTO_TCP, 00044 PROTO_UDP 00045 }; 00046 00048 Socket(); 00049 00051 virtual ~Socket(); 00052 00054 static void close( int socket ); 00055 00057 int id( void ) const { return soket_; }; 00058 00060 int port( void ) const { return port_; }; 00061 00063 static bool isValid( int socket ) { return socket != -1; }; 00064 00066 static void setBlocking( int socket, bool enable ); 00067 00069 virtual int writeBuffer(const void *buffer, long bufferSize, int flags = 0) = 0; 00070 00072 virtual int readBuffer(void *buffer, long bufferSize, int flags = 0) = 0; 00073 00075 static int writeBuffer(int socket, const void *buffer, long bufferSize, int flags ); 00076 00078 static int readBuffer(int socket, void *buffer, long bufferSize, int flags ); 00079 00080 protected: 00081 00082 int soket_; 00083 int port_; 00084 00085 }; 00086 00087 } // stk namespace 00088 00089 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |