diff options
author | Radomir Dopieralski <openstack@sheep.art.pl> | 2015-05-26 23:34:31 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-30 12:49:58 +0100 |
commit | 78ccb44a90584387dba6cfbdaa19fb651a6f64ab (patch) | |
tree | b885ce8fba8a0bb63025cdc679e2e37cea23b289 /docs/library/esp.socket.rst | |
parent | 278d22ce8f9c5b51778f70d36088a986f1b6adc8 (diff) |
docs: Document esp module for ESP8266.
I document as much as I could guess from experiments and reading the
code for the ``esp`` module for the ESP8266 port of Micropython.
For now the tag has to be set manually with -t option when building,
when we have properly split documentation, there will be a separate
config file for esp8266 with that the tag "port_esp8266" set.
To build use:
make SPHINXOPTS="-t port_esp8266" html
Diffstat (limited to 'docs/library/esp.socket.rst')
-rw-r--r-- | docs/library/esp.socket.rst | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/docs/library/esp.socket.rst b/docs/library/esp.socket.rst new file mode 100644 index 000000000..4f5234a15 --- /dev/null +++ b/docs/library/esp.socket.rst @@ -0,0 +1,82 @@ +class socket -- network socket +============================== + +``socket`` is an object that represents a network socket. Example usage:: + + socket = esp.socket() + socket.onrecv(print) + socket.connect(('207.58.139.247', 80)) + socket.send('GET /testwifi/index.html HTTP/1.0\r\n\r\n') + +Constructors +------------ + +.. class:: esp.socket() + + Create and return a socket object. + + +TCP Methods +----------- + +.. method:: socket.connect(addr) + + Connect to the adress and port specified in the ``addr`` tuple. + +.. method:: socket.close() + + Close the connection. + +.. method:: socket.accept() + + Accept a single connection from the connection queue. + +.. method:: socket.listen(backlog) + + Start listening for incoming connections. + + Note: Only one socket can be listening for connections at a time. + +.. method:: socket.bind(addr) + + Bind the socket to the address and port specified by the ``addr`` tuple. + +.. method:: socket.send(buf) + + Send the bytes from ``buf``. + +.. method:: socket.recv() + + Receive and return bytes from the socket. + + +UDP Methods +----------- + +.. method:: socket.sendto(data, addr) + + Placeholder for UDP support, not implemented yet. + +.. method:: socket.recvfrom(addr) + + Placeholder for UDP support, not implemented yet. + + +Callback Setter Methods +----------------------- + +.. method:: onconnect(lambda):: + + When connection is established, call the callback ``lambda``. + +.. method:: onrecv(lambda):: + + When data is received, call the callback ``lambda``. + +.. method:: onsent(lamda):: + + What data is finished sending, call the callback ``lambda``. + +.. method:: ondisconnect(lambda):: + + Call the callback ``lambda`` when the connection is closed. |