1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2004 Chris Schoeneman
|
---|
4 | *
|
---|
5 | * This package is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * found in the file COPYING that should have accompanied this file.
|
---|
8 | *
|
---|
9 | * This package 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.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef IDATASOCKET_H
|
---|
16 | #define IDATASOCKET_H
|
---|
17 |
|
---|
18 | #include "ISocket.h"
|
---|
19 | #include "IStream.h"
|
---|
20 |
|
---|
21 | //! Data stream socket interface
|
---|
22 | /*!
|
---|
23 | This interface defines the methods common to all network sockets that
|
---|
24 | represent a full-duplex data stream.
|
---|
25 | */
|
---|
26 | class IDataSocket : public ISocket, public IStream {
|
---|
27 | public:
|
---|
28 | class CConnectionFailedInfo {
|
---|
29 | public:
|
---|
30 | // pointer to a string describing the failure
|
---|
31 | char m_what[1];
|
---|
32 | };
|
---|
33 |
|
---|
34 | //! @name manipulators
|
---|
35 | //@{
|
---|
36 |
|
---|
37 | //! Connect socket
|
---|
38 | /*!
|
---|
39 | Attempt to connect to a remote endpoint. This returns immediately
|
---|
40 | and sends a connected event when successful or a connection failed
|
---|
41 | event when it fails. The stream acts as if shutdown for input and
|
---|
42 | output until the stream connects.
|
---|
43 | */
|
---|
44 | virtual void connect(const CNetworkAddress&) = 0;
|
---|
45 |
|
---|
46 | //@}
|
---|
47 | //! @name accessors
|
---|
48 | //@{
|
---|
49 |
|
---|
50 | //! Get connected event type
|
---|
51 | /*!
|
---|
52 | Returns the socket connected event type. A socket sends this
|
---|
53 | event when a remote connection has been established.
|
---|
54 | */
|
---|
55 | static CEvent::Type getConnectedEvent();
|
---|
56 |
|
---|
57 | //! Get connection failed event type
|
---|
58 | /*!
|
---|
59 | Returns the socket connection failed event type. A socket sends
|
---|
60 | this event when an attempt to connect to a remote port has failed.
|
---|
61 | The data is a pointer to a CConnectionFailedInfo.
|
---|
62 | */
|
---|
63 | static CEvent::Type getConnectionFailedEvent();
|
---|
64 |
|
---|
65 | //@}
|
---|
66 |
|
---|
67 | // ISocket overrides
|
---|
68 | // close() and getEventTarget() aren't pure to work around a bug
|
---|
69 | // in VC++6. it claims the methods are unused locals and warns
|
---|
70 | // that it's removing them. it's presumably tickled by inheriting
|
---|
71 | // methods with identical signatures from both superclasses.
|
---|
72 | virtual void bind(const CNetworkAddress&) = 0;
|
---|
73 | virtual void close();
|
---|
74 | virtual void* getEventTarget() const;
|
---|
75 |
|
---|
76 | // IStream overrides
|
---|
77 | virtual UInt32 read(void* buffer, UInt32 n) = 0;
|
---|
78 | virtual void write(const void* buffer, UInt32 n) = 0;
|
---|
79 | virtual void flush() = 0;
|
---|
80 | virtual void shutdownInput() = 0;
|
---|
81 | virtual void shutdownOutput() = 0;
|
---|
82 | virtual bool isReady() const = 0;
|
---|
83 | virtual UInt32 getSize() const = 0;
|
---|
84 |
|
---|
85 | private:
|
---|
86 | static CEvent::Type s_connectedEvent;
|
---|
87 | static CEvent::Type s_failedEvent;
|
---|
88 | };
|
---|
89 |
|
---|
90 | #endif
|
---|