3 Copyright (c) 2011-2013 ARM Limited
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
17 # Be sure that the tools directory is in the search path
19 from os.path import join, abspath, dirname
20 ROOT = abspath(join(dirname(__file__), "..", ".."))
21 sys.path.insert(0, ROOT)
23 from workspace_tools.private_settings import LOCALHOST
24 from SocketServer import BaseRequestHandler, TCPServer
27 class TCP_EchoHandler(BaseRequestHandler):
29 print "\nHandle connection from:", self.client_address
31 data = self.request.recv(1024)
33 self.request.sendall(data)
37 if __name__ == '__main__':
38 server = TCPServer((LOCALHOST, 7), TCP_EchoHandler)
39 print "listening for connections on:", (LOCALHOST, 7)
40 server.serve_forever()