Fork me on GitHub

Project Notes

#068 Twisted Client-Server with Tests

Twisted is an event-driven networking engine written in Python.

This is an invetsigation of test-driving custom client-server code with twisted, following the examples from the Test-driven development with Twisted tutorial.

Installing and Running the Tests

$ pip install -r requirements.txt
$ nosetests
.................
----------------------------------------------------------------------
Ran 17 tests in 0.145s

OK

Using the Calculus Server

$ export PYTHONPATH="$PYTHONPATH:`pwd`/calculus"
$ python calculus/server.py
2016-04-18 20:47:08+0800 [-] Log opened.
2016-04-18 20:47:08+0800 [-] RemoteCalculationFactory starting on 58522
2016-04-18 20:47:08+0800 [-] Starting factory <__main__.RemoteCalculationFactory instance at 0x10a4fb488>

in another window:

$ telnet localhost 58522
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
add 4123 9423
13546

or with netcat (since telnet becoming vanishingly rare!)

$  nc -c localhost 58522
subtract 12345 4123
8222
add 4123 8222
12345

Credits and References

About LCK#68 python
Project Source on GitHub Return to the Project Catalog

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.

LittleArduinoProjects LittleModelArt More on my blog