nidas  v1.2-1520
BluetoothRFCommSocket.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2010, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 
27 #include <nidas/Config.h> // HAVE_BLUETOOTH_RFCOMM_H
28 
29 #ifdef HAVE_BLUETOOTH_RFCOMM_H
30 
31 #ifndef NIDAS_UTIL_BLUETOOTHRFCOMMSOCKET_H
32 #define NIDAS_UTIL_BLUETOOTHRFCOMMSOCKET_H
33 
35 #include "IOException.h"
36 
37 namespace nidas { namespace util {
38 
42 class BluetoothRFCommSocket {
43 public:
44 
53  BluetoothRFCommSocket() throw(IOException);
54 
58  BluetoothRFCommSocket(const BluetoothAddress& addr,int channel)
59  throw(IOException);
60 
64  BluetoothRFCommSocket(const std::string& addr,int channel)
65  throw(UnknownHostException,IOException);
66 
70  BluetoothRFCommSocket(const SocketAddress& addr) throw(IOException);
71 
76  BluetoothRFCommSocket(int fd, const SocketAddress& raddr) throw(IOException);
77 
81  BluetoothRFCommSocket(const BluetoothRFCommSocket&);
82 
86  BluetoothRFCommSocket& operator = (const BluetoothRFCommSocket& rhs);
87 
91  ~BluetoothRFCommSocket() throw();
92 
93  void close() throw(IOException);
94 
102  void setTimeout(int val);
103 
104  int getTimeout() const;
105 
111  void setNonBlocking(bool val) throw(IOException);
112 
113  bool isNonBlocking() const throw(IOException);
114 
127  void connect(const std::string& addr,int channel)
128  throw(UnknownHostException,IOException);
129 
133  void connect(const BluetoothAddress& addr, int channel)
134  throw(IOException);
135 
139  void connect(const SocketAddress& addr)
140  throw(IOException);
141 
155  void bind(int channel) throw(IOException);
156 
157  void bind(const BluetoothAddress& addr,int channel)
158  throw(IOException);
159 
160  void bind(const SocketAddress& sockaddr) throw(IOException);
161 
162  void listen() throw(IOException);
163 
164  BluetoothRFCommSocket* accept() throw(IOException);
165 
169  int getFd() const { return _fd; }
170 
171  size_t recv(void* buf, size_t len, int flags = 0)
172  throw(IOException);
173 
180  size_t send(const void* buf, size_t len, int flags=0)
181  throw(IOException);
182 
183  size_t send(const struct iovec* iov, int iovcnt, int flags=MSG_NOSIGNAL)
184  throw(IOException);
185 
197  void sendall(const void* buf, size_t len, int flags=MSG_NOSIGNAL)
198  throw(IOException);
199 
203  const SocketAddress& getRemoteSocketAddress() const throw();
204 
209  int getRemotePort() const throw();
210 
214  const SocketAddress& getLocalSocketAddress() const throw();
215 
220  int getLocalPort() const throw();
221 
222  int getDomain() const { return AF_BLUETOOTH; }
223 
224 private:
225 
229  void getLocalAddr() throw(IOException);
230 
234  void getRemoteAddr() throw(IOException);
235 
236  int _fd;
237 
238  SocketAddress* _localaddr;
239 
240  SocketAddress* _remoteaddr;
241 
242  bool _hasTimeout;
243 
244  struct timespec _timeout;
245 
246 };
247 
248 
249 }} // namespace nidas namespace util
250 
251 #endif
252 #endif
int len
Definition: sing.cc:934
int fd
Definition: twod.c:56