Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Socket.h

00001 /***************************************************/
00012 /***************************************************/
00013 
00014 #ifndef STK_SOCKET_H
00015 #define STK_SOCKET_H
00016 
00017 #include "Stk.h"
00018 
00019 #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
00020 
00021   #include <sys/socket.h>
00022   #include <sys/types.h>
00023   #include <arpa/inet.h>
00024   #include <netdb.h>
00025   #include <unistd.h>
00026   #include <fcntl.h>
00027   #include <netinet/in.h>
00028   #include <netinet/tcp.h>
00029 
00030 #elif defined(__OS_WINDOWS__)
00031 
00032   #include <winsock.h>
00033 
00034 #endif
00035 
00036 class Socket : public Stk
00037 {
00038  public:
00039 
00040   enum ProtocolType {
00041     PROTO_TCP,
00042     PROTO_UDP
00043   };
00044 
00046   Socket();
00047 
00049   virtual ~Socket();
00050 
00052   static void close( int socket );
00053 
00055   int id( void ) const;
00056 
00058   int port( void ) const;
00059 
00061   static bool isValid( int socket );
00062 
00064   static void setBlocking( int socket, bool enable );
00065 
00067   virtual int writeBuffer(const void *buffer, long bufferSize, int flags = 0) = 0;
00068 
00070   virtual int readBuffer(void *buffer, long bufferSize, int flags = 0) = 0;
00071 
00073   static int writeBuffer(int socket, const void *buffer, long bufferSize, int flags );
00074 
00076   static int readBuffer(int socket, void *buffer, long bufferSize, int flags );
00077 
00078  protected:
00079 
00080   int soket_;
00081   int port_;
00082 
00083 };
00084 
00085 #endif // defined(STK_SOCKET_H)

The Synthesis ToolKit in C++ (STK)
©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved.