00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __JackSocket__
00021 #define __JackSocket__
00022
00023 #include <sys/types.h>
00024 #include <sys/un.h>
00025 #include <sys/socket.h>
00026 #include <sys/ioctl.h>
00027 #include <sys/time.h>
00028 #include <arpa/inet.h>
00029 #include <errno.h>
00030 #include <unistd.h>
00031
00032 namespace Jack
00033 {
00034
00039 class JackClientSocket
00040 {
00041
00042 private:
00043
00044 int fSocket;
00045 int fTimeOut;
00046
00047 public:
00048
00049 JackClientSocket(): fSocket( -1),fTimeOut(0)
00050 {}
00051 JackClientSocket(int socket);
00052
00053 int Connect(const char* dir, const char* name, int which);
00054 int Close();
00055 int Read(void* data, int len);
00056 int Write(void* data, int len);
00057 int GetFd()
00058 {
00059 return fSocket;
00060 }
00061 void SetReadTimeOut(long sec);
00062 void SetWriteTimeOut(long sec);
00063
00064 void SetNonBlocking(bool onoff);
00065 };
00066
00071 #define SOCKET_MAX_NAME_SIZE 256
00072
00073
00074 class JackServerSocket
00075 {
00076
00077 private:
00078
00079 int fSocket;
00080 char fName[SOCKET_MAX_NAME_SIZE];
00081
00082 public:
00083
00084 JackServerSocket(): fSocket( -1)
00085 {}
00086 ~JackServerSocket()
00087 {}
00088
00089 int Bind(const char* dir, const char* name, int which);
00090 JackClientSocket* Accept();
00091 int Close();
00092 int GetFd()
00093 {
00094 return fSocket;
00095 }
00096 };
00097
00098 }
00099
00100 #endif
00101