Explorar o código

【完善】usocket

SummerGift %!s(int64=6) %!d(string=hai) anos
pai
achega
0a3e3669c7
Modificáronse 1 ficheiros con 25 adicións e 25 borrados
  1. 25 25
      docs/code-completion/uscoket.py

+ 25 - 25
docs/code-completion/uscoket.py

@@ -13,17 +13,17 @@ SO_REUSEADDR = ...  # type: int
 IPPROTO_TCP  = ...  # type: int
 IPPROTO_UDP  = ...  # type: int
 
-class socket(family, type, protocol) -> None:
-    """
-    创建新的套接字,使用指定的地址、类型和协议号。
-    - usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM)
-    """
-    ...
 
-    def __init__(self) -> None:
-    ...
+class socket(object) -> None:
 
-    def getaddrinfo(host, port) -> None:
+    def __init__(self, family, type, protocol) -> None:
+        """
+        创建新的套接字,使用指定的地址、类型和协议号。
+        - usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM)
+        """
+        ...
+
+    def getaddrinfo(self, host, port) -> None:
         """
         将主机域名(host)和端口(port)转换为用于创建套接字的5元组序列。元组列表的结构如下:
 
@@ -36,15 +36,15 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def close() -> None:
+    def close(self) -> None:
         """关闭套接字。一旦关闭后,套接字所有的功能都将失效。远端将接收不到任何数据 (清理队列数据后)。 虽然在垃圾回收时套接字会自动关闭,但还是推荐在必要时用 close() 去关闭。"""
         ...
 
-    def bind(address) -> None:
+    def bind(self, address) -> None:
         """将套接字绑定到地址,套接字不能是已经绑定的。"""
         ...
 
-    def listen(backlog) -> None:
+    def listen(self, backlog) -> None:
         """
         listen([backlog])
         监听套接字,使服务器能够接收连接。
@@ -52,7 +52,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def accept() -> None:
+    def accept(self) -> None:
         """
         接收连接请求。 注意: 只能在绑定地址端口号和监听后调用,返回 conn 和 address。
 
@@ -61,7 +61,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def connect(address) -> None:
+    def connect(self, address) -> None:
         """
         连接服务器。
 
@@ -69,7 +69,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def send(bytes) -> None:
+    def send(self, bytes) -> None:
         """
         发送数据,并返回成功发送的字节数,返回字节数可能比发送的数据长度少。
 
@@ -77,7 +77,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def recv(bufsize) -> None:
+    def recv(self, bufsize) -> None:
         """
         接收数据,返回接收到的数据对象。
 
@@ -88,7 +88,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def sendto(bytes, address) -> None:
+    def sendto(self, bytes, address) -> None:
         """
         送数据,目标由address决定,常用于UDP通信,返回发送的数据大小。
 
@@ -101,7 +101,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def recvfrom(bufsize) -> None:
+    def recvfrom(self, bufsize) -> None:
         """
         接收数据,常用于UDP通信,并返回接收到的数据对象和对象的地址。
 
@@ -112,7 +112,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def setsockopt(level, optname, value) -> None:
+    def setsockopt(self, level, optname, value) -> None:
         """
         根据选项值设置套接字。
 
@@ -125,7 +125,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def settimeout(value) -> None:
+    def settimeout(self, value) -> None:
         """
         设置超时时间,单位:秒。 示例:
 
@@ -133,13 +133,13 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def setblocking(flag) -> None:
+    def setblocking(self, flag) -> None:
         """
         设置阻塞或非阻塞模式: 如果 flag 是 false,设置非阻塞模式。
         """
         ...
 
-    def read(size) -> None:
+    def read(self, size) -> None:
         """
         - read([size])
         Read up to size bytes from the socket. 
@@ -149,7 +149,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def readinto(buf) -> None:
+    def readinto(self, buf) -> None:
         """
         readinto(buf[, nbytes])
         Read bytes into the buf. 
@@ -160,13 +160,13 @@ class socket(family, type, protocol) -> None:
         """
         ...
         
-    def readline() -> None:
+    def readline(self) -> None:
         """
         接收一行数据,遇换行符结束,并返回接收数据的对象 。
         """
         ...
 
-    def write(buf) -> None:
+    def write(self, buf) -> None:
         """
         将字节类型数据写入套接字,并返回写入成功的数据大小。
         """