Fix a conflict with Audio Hijack in JackCoreAudioDriver.
[jack2.git] / posix / JackNetUnixSocket.h
blobfd6393709a5b324744cad574537798b191ed75bc
1 /*
2 Copyright (C) 2008 Romain Moret at Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackNetUnixSocket__
21 #define __JackNetUnixSocket__
23 #include "JackNetSocket.h"
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <netdb.h>
27 #include <netinet/in.h>
28 #include <arpa/inet.h>
30 namespace Jack
32 #define NET_ERROR_CODE errno
33 #define SOCKET_ERROR -1
34 #define StrError strerror
36 typedef struct sockaddr socket_address_t;
37 typedef struct in_addr address_t;
39 //JackNetUnixSocket********************************************
40 class SERVER_EXPORT JackNetUnixSocket
42 private:
43 int fSockfd;
44 int fPort;
46 struct sockaddr_in fSendAddr;
47 struct sockaddr_in fRecvAddr;
48 public:
49 JackNetUnixSocket();
50 JackNetUnixSocket ( const char* ip, int port );
51 JackNetUnixSocket ( const JackNetUnixSocket& );
52 ~JackNetUnixSocket();
54 JackNetUnixSocket& operator= ( const JackNetUnixSocket& socket );
56 //socket management
57 int NewSocket();
58 int Bind();
59 int BindWith ( const char* ip );
60 int BindWith ( int port );
61 int Connect();
62 int ConnectTo ( const char* ip );
63 void Close();
64 void Reset();
65 bool IsSocket();
67 //IP/PORT management
68 void SetPort ( int port );
69 int GetPort();
71 //address management
72 int SetAddress ( const char* ip, int port );
73 char* GetSendIP();
74 char* GetRecvIP();
76 //utility
77 int GetName ( char* name );
78 int JoinMCastGroup ( const char* mcast_ip );
80 //options management
81 int SetOption ( int level, int optname, const void* optval, socklen_t optlen );
82 int GetOption ( int level, int optname, void* optval, socklen_t* optlen );
84 //timeout
85 int SetTimeOut ( int us );
87 //disable local loop
88 int SetLocalLoop();
90 //network operations
91 int SendTo ( const void* buffer, size_t nbytes, int flags );
92 int SendTo ( const void* buffer, size_t nbytes, int flags, const char* ip );
93 int Send ( const void* buffer, size_t nbytes, int flags );
94 int RecvFrom ( void* buffer, size_t nbytes, int flags );
95 int Recv ( void* buffer, size_t nbytes, int flags );
96 int CatchHost ( void* buffer, size_t nbytes, int flags );
98 //error management
99 net_error_t GetError();
103 #endif