Sample to show hanging during socket initialization
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
sample server (python) to go with the RTOSTest
Import programRTOSTest
Sample to show hanging during socket initialization
#!/usr/bin/python2.7
import sys, os
import asyncore, socket
import time, datetime
class EchoClient(asyncore.dispatcher_with_send):
def handle_read(self):
buffer = self.recv(1024)
if buffer:
print str(datetime.datetime.fromtimestamp(time.time()))
print buffer
else:
self.close()
class Server(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.bind(('', port))
self.listen(8)
def handle_accept(self):
socket, address = self.accept()
print str(datetime.datetime.fromtimestamp(time.time()))
print 'Connection by', address
EchoClient(socket)
s = Server('', 8080)
asyncore.loop()
EthernetInterface.lib@1:92d3f1118200, 2012-09-27 (annotated)
- Committer:
- jonathonfletcher
- Date:
- Thu Sep 27 12:14:57 2012 +0000
- Revision:
- 1:92d3f1118200
- Parent:
- 0:5197a41c178f
add server_ip and server_port at the top of the example.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jonathonfletcher | 0:5197a41c178f | 1 | http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa |
