I am new to TCP socket programming. I have a django based server communicating with a microcontroller. Now, I want to implement TCP based socket on the server side in order to communicate with the TCP socket on the microcontroller. Can anyone give me an idea on how to do this ? What libraries should I use on my django server The microprocessor basically opens the socket every 5 seconds and sends a notification to the server. I on the server side should be able to read this and pump data back to the microprocessor using this socket which was opened by the microprocessor.
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Socket编程 TCP方式发送时间有点长
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Django is sooo slow? errno 32 broken pipe? dcramer
- Django: Replacement for the default ManyToMany Wid
- Upgrading transaction.commit_manually() to Django
If you are already familiar with django, and your microcontroller supports sending HTTP (REST) requests and can parse Json , you can just add a regular django based view that returns json:
However, if your microcontroller is very simple and cannot do HTTP/json, you can use a simple SocketServer from python's standard library instead:
Keep in mind you can still import django's libraries and use django's ORM (DB) inside a SocketServer.
Another popular option is to use Tornado's tcpserver: