| 1 | /*
|
|---|
| 2 | * synergy -- mouse and keyboard sharing utility
|
|---|
| 3 | * Copyright (C) 2002 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 ISOCKET_H
|
|---|
| 16 | #define ISOCKET_H
|
|---|
| 17 |
|
|---|
| 18 | #include "IInterface.h"
|
|---|
| 19 | #include "CEvent.h"
|
|---|
| 20 |
|
|---|
| 21 | class CNetworkAddress;
|
|---|
| 22 |
|
|---|
| 23 | //! Generic socket interface
|
|---|
| 24 | /*!
|
|---|
| 25 | This interface defines the methods common to all network sockets.
|
|---|
| 26 | Generated events use \c this as the target.
|
|---|
| 27 | */
|
|---|
| 28 | class ISocket : public IInterface {
|
|---|
| 29 | public:
|
|---|
| 30 | //! @name manipulators
|
|---|
| 31 | //@{
|
|---|
| 32 |
|
|---|
| 33 | //! Bind socket to address
|
|---|
| 34 | /*!
|
|---|
| 35 | Binds the socket to a particular address.
|
|---|
| 36 | */
|
|---|
| 37 | virtual void bind(const CNetworkAddress&) = 0;
|
|---|
| 38 |
|
|---|
| 39 | //! Close socket
|
|---|
| 40 | /*!
|
|---|
| 41 | Closes the socket. This should flush the output stream.
|
|---|
| 42 | */
|
|---|
| 43 | virtual void close() = 0;
|
|---|
| 44 |
|
|---|
| 45 | //@}
|
|---|
| 46 | //! @name accessors
|
|---|
| 47 | //@{
|
|---|
| 48 |
|
|---|
| 49 | //! Get event target
|
|---|
| 50 | /*!
|
|---|
| 51 | Returns the event target for events generated by this socket.
|
|---|
| 52 | */
|
|---|
| 53 | virtual void* getEventTarget() const = 0;
|
|---|
| 54 |
|
|---|
| 55 | //! Get disconnected event type
|
|---|
| 56 | /*!
|
|---|
| 57 | Returns the socket disconnected event type. A socket sends this
|
|---|
| 58 | event when the remote side of the socket has disconnected or
|
|---|
| 59 | shutdown both input and output.
|
|---|
| 60 | */
|
|---|
| 61 | static CEvent::Type getDisconnectedEvent();
|
|---|
| 62 |
|
|---|
| 63 | //@}
|
|---|
| 64 |
|
|---|
| 65 | private:
|
|---|
| 66 | static CEvent::Type s_disconnectedEvent;
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | #endif
|
|---|