2 /// \file m_raw_socket.h
3 /// Mode class for a raw socket
7 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
8 Portions Copyright (C) 2010 RealVNC Ltd.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #ifndef __BARRY_M_RAW_SOCKET_H__
24 #define __BARRY_M_RAW_SOCKET_H__
27 #include "m_mode_base.h"
34 // Callback from the raw socket.
36 class BXEXPORT RawSocketDataCallback
39 virtual void DataReceived(Data
& data
) = 0;
40 virtual ~RawSocketDataCallback() {};
43 #define RAW_SOCKET_HEADER_SIZE 4
44 #define RAW_SOCKET_MAXIMUM_PACKET_SIZE 16384
45 #define RAW_SOCKET_MAXIMUM_PACKET_CONTENTS_SIZE (RAW_SOCKET_MAXIMUM_PACKET_SIZE - RAW_SOCKET_HEADER_SIZE)
50 /// The main class for creating a raw socket session.
52 /// To use this class, use the following steps:
54 /// - Implement RawSocketDataCallback
55 /// - Create a Controller object (see Controller class for more details)
56 /// - Create this Mode::RawSocket object, passing in the Controller
57 /// object during construction
58 /// - Call Open() to open database socket and finish constructing.
59 /// - Call GetData() to fetch data
60 /// - Call SendData() to send data
62 class BXEXPORT RawSocket
: public Mode
65 RawSocket(Controller
&con
, RawSocketDataCallback
& callback
);
68 //////////////////////////////////
69 // Raw Socket mode specific methods
71 // Send some data on the raw socket
72 // Will throw an error if data is longer than
73 // RAW_SOCKET_MAXIMUM_PACKET_CONTENTS_SIZE
74 void Send(Data
& data
);
76 void HandleReceivedData(Data
& data
);
81 RawSocketDataCallback
& Callback
;
82 unsigned char m_sendBuffer
[RAW_SOCKET_MAXIMUM_PACKET_SIZE
];
86 }} // namespace Barry::Mode