Skip to content
Snippets Groups Projects
Select Git revision
  • a0c296f6d515b0a18306213cf64d9580875448f6
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

network.rst

Blame
  • network.rst 17.11 KiB

    :mod:`network` --- network configuration

    This module provides network drivers and routing configuration. Network drivers for specific hardware are available within this module and are used to configure a hardware network interface. Configured interfaces are then available for use via the :mod:`socket` module. To use this module the network build of firmware must be installed.

    For example:

    # configure a specific network interface
    # see below for examples of specific drivers
    import network
    nic = network.Driver(...)
    print(nic.ifconfig())
    
    # now use socket as usual
    import socket
    addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
    s = socket.socket()
    s.connect(addr)
    s.send(b'GET / HTTP/1.1\r\nHost: micropython.org\r\n\r\n')
    data = s.recv(1000)
    s.close()