00001
00016 #ifndef PUTTY_EPOCNET_H
00017 #define PUTTY_EPOCNET_H
00018
00019 #include <e32std.h>
00020 #include <e32base.h>
00021 #include <w32std.h>
00022 #include <apgtask.h>
00023 #include <es_sock.h>
00024 #include <in_sock.h>
00025
00026
00032 class MSocketWatcher {
00033 public:
00035 virtual void SocketOpened() = 0;
00036
00038 virtual void SocketClosed() = 0;
00039 };
00040
00041
00050 void sk_set_watcher(MSocketWatcher *aWatcher);
00051
00052
00058 int sk_num_active_sockets(void);
00059
00060
00061 class CNetAS : public CActiveScheduler
00062 {
00063 void Error(TInt err) const
00064 {
00065 _LIT(KMsgErr,"CNetAS-error");
00066 User::Panic(KMsgErr,err);
00067 };
00068 };
00069
00070 class CRecver : public CActive
00071 {
00072 public:
00073 static CRecver *NewL(Socket p);
00074 ~CRecver();
00075 void StartRecver();
00076 void Reissue();
00077 private:
00078 CRecver();
00079 void ConstructL(Socket p);
00080 void RunL();
00081 void DoCancel();
00082 void DoRunL();
00083
00084 private:
00085 TBuf8<2048> readbuf;
00086 TSockXfrLength readlen;
00087 Socket parent;
00088 };
00089
00090 class CSender : public CActive
00091 {
00092 public:
00093 static CSender *NewL(Socket p);
00094 ~CSender();
00095 void Sendit();
00096 private:
00097 CSender();
00098 void ConstructL(Socket p);
00099 void RunL();
00100 void DoCancel();
00101 void DoRunL();
00102
00103 private:
00104 TPtrC8 writebuf;
00105 Socket parent;
00106 };
00107
00108 class CAcceptor : public CActive
00109 {
00110 public:
00111 static CAcceptor *NewL(Socket p);
00112 ~CAcceptor();
00113 void StartAcceptor();
00114 private:
00115 CAcceptor();
00116 void ConstructL(Socket p);
00117 void RunL();
00118 void DoCancel();
00119 void DoRunL();
00120
00121 private:
00122 Socket parent;
00123 };
00124
00125 class RSocketS : public RSocket
00126 {
00127 public:
00128 TInt id, selectflags;
00129 TRequestStatus estat;
00130 CRecver *r;
00131 CSender *s;
00132 CAcceptor *a;
00133 };
00134
00135
00136 #ifndef SOCKET
00137 #define SOCKET RSocketS *
00138 #endif
00139
00140 #ifndef INVALID_SOCKET
00141 #define INVALID_SOCKET NULL
00142 #endif
00143
00144 #ifndef SOCKET_ERROR
00145 #define SOCKET_ERROR NULL
00146 #endif
00147
00148 #define KInvalSocket 100
00149 #define MAXSOCKETS 10
00150
00151 #define FD_CONNECT 1
00152 #define FD_READ 2
00153 #define FD_WRITE 3
00154 #define FD_EXCEPTION 4
00155
00156 #endif