Is there a difference between usocket and socket?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Jim.S
Posts: 84
Joined: Fri Dec 18, 2015 7:36 pm

Is there a difference between usocket and socket?

Post by Jim.S » Sun Jun 30, 2019 12:06 pm

Are there any differences between import socket and import usocket

This micropython 1.11 document (https://docs.micropython.org/en/latest/ ... twork.html) uses the following import

Code: Select all

 # now use usocket as usual
import usocket as socket
But this example, for the esp 8266 which also works on the Pyboard-d ( https://docs.micropython.org/en/latest/ ... k_tcp.html) just uses import socket

Christian Walther
Posts: 52
Joined: Fri Aug 19, 2016 11:55 am

Re: Is there a difference between usocket and socket?

Post by Christian Walther » Sun Jun 30, 2019 12:22 pm

Unless you have a socket.py on your filesystem, there is no difference, they will both give you the same thing:

Code: Select all

MicroPython v1.11-8-g48dcbbe60 on 2019-05-29; ESP module with ESP8266
Type "help()" for more information.
>>> import usocket
>>> import socket
>>> socket
<module 'lwip'>
>>> usocket
<module 'lwip'>
>>> socket is usocket
True
See also http://docs.micropython.org/en/latest/l ... -libraries.

Post Reply