Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Socket.h
1 #ifndef STK_SOCKET_H
2 #define STK_SOCKET_H
3 
4 #include "Stk.h"
5 
6 #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
7 
8  #include <sys/socket.h>
9  #include <sys/types.h>
10  #include <arpa/inet.h>
11  #include <netdb.h>
12  #include <unistd.h>
13  #include <fcntl.h>
14  #include <netinet/in.h>
15  #include <netinet/tcp.h>
16 
17 #elif defined(__OS_WINDOWS__)
18 
19  #include <winsock.h>
20 
21 #endif
22 
23 namespace stk {
24 
25 /***************************************************/
36 /***************************************************/
37 
38 class Socket : public Stk
39 {
40  public:
41 
42  enum ProtocolType {
43  PROTO_TCP,
44  PROTO_UDP
45  };
46 
48  Socket();
49 
51  virtual ~Socket();
52 
54  static void close( int socket );
55 
57  int id( void ) const { return soket_; };
58 
60  int port( void ) const { return port_; };
61 
63  static bool isValid( int socket ) { return socket != -1; };
64 
66  static void setBlocking( int socket, bool enable );
67 
69  virtual int writeBuffer(const void *buffer, long bufferSize, int flags = 0) = 0;
70 
72  virtual int readBuffer(void *buffer, long bufferSize, int flags = 0) = 0;
73 
75  static int writeBuffer(int socket, const void *buffer, long bufferSize, int flags );
76 
78  static int readBuffer(int socket, void *buffer, long bufferSize, int flags );
79 
80  protected:
81 
82  int soket_;
83  int port_;
84 
85 };
86 
87 } // stk namespace
88 
89 #endif

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