source: trunk/synergy/lib/net/CTCPSocket.h

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 2.1 KB
Line 
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 CTCPSOCKET_H
16#define CTCPSOCKET_H
17
18#include "IDataSocket.h"
19#include "CStreamBuffer.h"
20#include "CCondVar.h"
21#include "CMutex.h"
22#include "IArchNetwork.h"
23
24class CMutex;
25class CThread;
26class ISocketMultiplexerJob;
27
28//! TCP data socket
29/*!
30A data socket using TCP.
31*/
32class CTCPSocket : public IDataSocket {
33public:
34 CTCPSocket();
35 CTCPSocket(CArchSocket);
36 ~CTCPSocket();
37
38 // ISocket overrides
39 virtual void bind(const CNetworkAddress&);
40 virtual void close();
41 virtual void* getEventTarget() const;
42
43 // IStream overrides
44 virtual UInt32 read(void* buffer, UInt32 n);
45 virtual void write(const void* buffer, UInt32 n);
46 virtual void flush();
47 virtual void shutdownInput();
48 virtual void shutdownOutput();
49 virtual bool isReady() const;
50 virtual UInt32 getSize() const;
51
52 // IDataSocket overrides
53 virtual void connect(const CNetworkAddress&);
54
55private:
56 void init();
57
58 void setJob(ISocketMultiplexerJob*);
59 ISocketMultiplexerJob* newJob();
60 void sendConnectionFailedEvent(const char*);
61 void sendEvent(CEvent::Type);
62
63 void onConnected();
64 void onInputShutdown();
65 void onOutputShutdown();
66 void onDisconnected();
67
68 ISocketMultiplexerJob*
69 serviceConnecting(ISocketMultiplexerJob*,
70 bool, bool, bool);
71 ISocketMultiplexerJob*
72 serviceConnected(ISocketMultiplexerJob*,
73 bool, bool, bool);
74
75private:
76 CMutex m_mutex;
77 CArchSocket m_socket;
78 CStreamBuffer m_inputBuffer;
79 CStreamBuffer m_outputBuffer;
80 CCondVar<bool> m_flushed;
81 bool m_connected;
82 bool m_readable;
83 bool m_writable;
84};
85
86#endif
Note: See TracBrowser for help on using the repository browser.