nidas v1.2.3
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
37namespace nidas { namespace util {
38
42class BluetoothRFCommSocket {
43public:
44
55 BluetoothRFCommSocket();
56
62 BluetoothRFCommSocket(const BluetoothAddress& addr, int channel);
63
70 BluetoothRFCommSocket(const std::string& addr, int channel);
71
77 BluetoothRFCommSocket(const SocketAddress& addr);
78
85 BluetoothRFCommSocket(int fd, const SocketAddress& raddr);
86
90 BluetoothRFCommSocket(const BluetoothRFCommSocket&);
91
95 BluetoothRFCommSocket& operator = (const BluetoothRFCommSocket& rhs);
96
100 ~BluetoothRFCommSocket() throw();
101
105 void close();
106
114 void setTimeout(int val);
115
116 int getTimeout() const;
117
125 void setNonBlocking(bool val);
126
130 bool isNonBlocking() const;
131
147 void connect(const std::string& addr, int channel);
148
154 void connect(const BluetoothAddress& addr, int channel);
155
161 void connect(const SocketAddress& addr);
162
178 void bind(int channel);
179
183 void bind(const BluetoothAddress& addr, int channel);
184
188 void bind(const SocketAddress& sockaddr);
189
193 void listen();
194
198 BluetoothRFCommSocket* accept();
199
203 int getFd() const { return _fd; }
204
208 size_t recv(void* buf, size_t len, int flags = 0);
209
218 size_t send(const void* buf, size_t len, int flags=0);
219
223 size_t send(const struct iovec* iov, int iovcnt, int flags=MSG_NOSIGNAL);
224
238 void sendall(const void* buf, size_t len, int flags=MSG_NOSIGNAL);
239
245 const SocketAddress& getRemoteSocketAddress() const;
246
253 int getRemotePort() const;
254
260 const SocketAddress& getLocalSocketAddress() const;
261
268 int getLocalPort() const;
269
270 int getDomain() const { return AF_BLUETOOTH; }
271
272private:
273
279 void getLocalAddr();
280
286 void getRemoteAddr();
287
288 int _fd;
289
290 SocketAddress* _localaddr;
291
292 SocketAddress* _remoteaddr;
293
294 bool _hasTimeout;
295
296 struct timespec _timeout;
297
298};
299
300
301}} // namespace nidas namespace util
302
303#endif
304#endif
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948
int fd
Definition twod.c:56