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 #include "JackChannel.h"
00033
00034 namespace Jack
00035 {
00036
00041 class JackClientSocket : public detail::JackClientRequestInterface
00042 {
00043
00044 private:
00045
00046 int fSocket;
00047 int fTimeOut;
00048
00049 public:
00050
00051 JackClientSocket():JackClientRequestInterface(), fSocket(-1), fTimeOut(0)
00052 {}
00053 JackClientSocket(int socket);
00054
00055 int Connect(const char* dir, const char* name, int which);
00056 int Close();
00057 int Read(void* data, int len);
00058 int Write(void* data, int len);
00059 int GetFd()
00060 {
00061 return fSocket;
00062 }
00063 void SetReadTimeOut(long sec);
00064 void SetWriteTimeOut(long sec);
00065
00066 void SetNonBlocking(bool onoff);
00067 };
00068
00073 #define SOCKET_MAX_NAME_SIZE 256
00074
00075
00076 class JackServerSocket
00077 {
00078
00079 private:
00080
00081 int fSocket;
00082 char fName[SOCKET_MAX_NAME_SIZE];
00083
00084 public:
00085
00086 JackServerSocket(): fSocket( -1)
00087 {}
00088 ~JackServerSocket()
00089 {}
00090
00091 int Bind(const char* dir, const char* name, int which);
00092 JackClientSocket* Accept();
00093 int Close();
00094 int GetFd()
00095 {
00096 return fSocket;
00097 }
00098 };
00099
00100 }
00101
00102 #endif
00103