4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief telnetServer non-inline non-template implementation */
26 //#include "telnetServer.hh"
27 //#include "telnetServer.ih"
30 #include <boost/bind.hpp>
31 #include "../../Scheduler/Scheduler.hh"
32 #include "../Logger.hh"
33 #include "../../Socket/Protocols/INet.hh"
34 #include "TelnetTerminal.hh"
37 //#include "telnetServer.mpp"
39 ///////////////////////////////cc.p////////////////////////////////////////
44 : public senf::term::BaseEditor
47 MyEditor(senf::term::AbstractTerminal & terminal)
48 : BaseEditor(terminal) {}
51 virtual void v_keyReceived(keycode_t key)
53 SENF_LOG(("Key " << senf::term::KeyParser::describe(key)));
54 if (key >= ' ' && key < 256)
61 case senf::term::KeyParser::Left:
63 unsigned c (currentColumn());
68 case senf::term::KeyParser::Backspace:
70 unsigned c (currentColumn());
77 case senf::term::KeyParser::Delete:
86 : public senf::term::TelnetTerminal
89 explicit MyTelnet(Handle handle)
90 : senf::term::BaseTelnetProtocol(handle),
103 typedef senf::TCPv4ServerSocketHandle ServerHandle;
104 typedef ServerHandle::ClientHandle ClientHandle;
106 void connect(ServerHandle handle, int events)
108 if (events != senf::scheduler::FdEvent::EV_READ) {
109 senf::scheduler::terminate();
112 ClientHandle client (handle.accept());
113 SENF_LOG(("new client ..."));
114 new MyTelnet (client);
119 int main(int argc, char const ** argv)
121 senf::log::ConsoleTarget::instance().timeFormat("");
123 ServerHandle server (ServerHandle::Address("127.0.0.1:22344"));
124 senf::scheduler::FdEvent serverEvent ("telnetServer", boost::bind(&connect, server, _1),
125 server, senf::scheduler::FdEvent::EV_READ);
126 SENF_LOG(("Server started at " << server.local()));
128 senf::scheduler::process();
133 ///////////////////////////////cc.e////////////////////////////////////////
135 //#include "telnetServer.mpp"
141 // comment-column: 40
142 // c-file-style: "senf"
143 // indent-tabs-mode: nil
144 // ispell-local-dictionary: "american"
145 // compile-command: "scons -u telnetServer"