2 /// \file brawchannel.h
3 /// Directs a named raw channel over STDIN/STDOUT or TCP
7 Copyright (C) 2010-2012, RealVNC Ltd.
9 Some parts are inspired from bjavaloader.cc
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 See the GNU General Public License in the COPYING file at the
21 root directory of this project for more details.
24 #ifndef __BARRY_TOOLS_BRAWCHANNEL_H__
25 #define __BARRY_TOOLS_BRAWCHANNEL_H__
27 #include <sys/types.h>
30 // How long, in seconds, to wait between reads before checking if should shutdown
31 #define READ_TIMEOUT_SECONDS 1
33 /* Defined generic stream reading and writing classes.
35 * It'd be great to use iostream, but they don't provide non-blocking reads.
44 virtual ~InputStream() {};
45 virtual ssize_t
read(unsigned char* ptr
, size_t size
, int timeout
) = 0;
50 virtual ~OutputStream() {};
51 virtual ssize_t
write(const unsigned char* ptr
, size_t size
) = 0;
54 class StdOutStream
: public OutputStream
{
56 virtual ssize_t
write(const unsigned char* ptr
, size_t size
);
59 class StdInStream
: public InputStream
{
61 virtual ssize_t
read(unsigned char* ptr
, size_t size
, int timeout
);
64 // Forward declaration of platform implementation details
67 class TcpStream
: public Stream
{
69 std::auto_ptr
<TcpStreamImpl
> mImpl
;
71 TcpStream(const char * addr
, long port
);
76 class TcpInStream
: public InputStream
{
80 TcpInStream(TcpStream
& stream
)
82 virtual ssize_t
read(unsigned char* ptr
, size_t size
, int timeout
);
85 class TcpOutStream
: public OutputStream
{
89 TcpOutStream(TcpStream
& stream
)
92 virtual ssize_t
write(const unsigned char* ptr
, size_t size
);
95 #endif // __BARRY_TOOLS_BRAWCHANNEL_H__