Jack2 1.9.6

JackSocket.h

00001 /*
00002 Copyright (C) 2004-2008 Grame
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU Lesser General Public License as published by
00006 the Free Software Foundation; either version 2.1 of the License, or
00007 (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public License
00015 along with this program; if not, write to the Free Software 
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 } // end of namespace
00099 
00100 #endif
00101