basedpyright 1.12.6 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pyright-langserver.js +1 -1
- package/dist/pyright-langserver.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/typeshed-fallback/stdlib/_ast.pyi +279 -42
- package/dist/typeshed-fallback/stdlib/_bisect.pyi +149 -12
- package/dist/typeshed-fallback/stdlib/_codecs.pyi +125 -14
- package/dist/typeshed-fallback/stdlib/_csv.pyi +130 -7
- package/dist/typeshed-fallback/stdlib/_ctypes.pyi +72 -17
- package/dist/typeshed-fallback/stdlib/_curses.pyi +626 -78
- package/dist/typeshed-fallback/stdlib/_decimal.pyi +775 -153
- package/dist/typeshed-fallback/stdlib/_heapq.pyi +61 -5
- package/dist/typeshed-fallback/stdlib/_imp.pyi +70 -15
- package/dist/typeshed-fallback/stdlib/_json.pyi +55 -12
- package/dist/typeshed-fallback/stdlib/_locale.pyi +63 -12
- package/dist/typeshed-fallback/stdlib/_lsprof.pyi +61 -4
- package/dist/typeshed-fallback/stdlib/_operator.pyi +238 -62
- package/dist/typeshed-fallback/stdlib/_posixsubprocess.pyi +25 -1
- package/dist/typeshed-fallback/stdlib/_random.pyi +23 -5
- package/dist/typeshed-fallback/stdlib/_socket.pyi +618 -63
- package/dist/typeshed-fallback/stdlib/_stat.pyi +140 -13
- package/dist/typeshed-fallback/stdlib/_thread.pyi +215 -22
- package/dist/typeshed-fallback/stdlib/_tkinter.pyi +44 -11
- package/dist/typeshed-fallback/stdlib/_tracemalloc.pyi +71 -10
- package/dist/typeshed-fallback/stdlib/_warnings.pyi +53 -6
- package/dist/typeshed-fallback/stdlib/_weakref.pyi +43 -10
- package/dist/typeshed-fallback/stdlib/_winapi.pyi +255 -255
- package/dist/typeshed-fallback/stdlib/array.pyi +233 -44
- package/dist/typeshed-fallback/stdlib/atexit.pyi +50 -5
- package/dist/typeshed-fallback/stdlib/audioop.pyi +78 -26
- package/dist/typeshed-fallback/stdlib/binascii.pyi +105 -18
- package/dist/typeshed-fallback/stdlib/builtins.pyi +5254 -829
- package/dist/typeshed-fallback/stdlib/cmath.pyi +99 -23
- package/dist/typeshed-fallback/stdlib/errno.pyi +15 -0
- package/dist/typeshed-fallback/stdlib/faulthandler.pyi +33 -8
- package/dist/typeshed-fallback/stdlib/fcntl.pyi +199 -8
- package/dist/typeshed-fallback/stdlib/gc.pyi +130 -18
- package/dist/typeshed-fallback/stdlib/grp.pyi +58 -7
- package/dist/typeshed-fallback/stdlib/itertools.pyi +281 -42
- package/dist/typeshed-fallback/stdlib/marshal.pyi +82 -4
- package/dist/typeshed-fallback/stdlib/math.pyi +357 -61
- package/dist/typeshed-fallback/stdlib/mmap.pyi +47 -8
- package/dist/typeshed-fallback/stdlib/msvcrt.pyi +32 -32
- package/dist/typeshed-fallback/stdlib/nt.pyi +118 -111
- package/dist/typeshed-fallback/stdlib/parser.pyi +55 -24
- package/dist/typeshed-fallback/stdlib/posix.pyi +7 -0
- package/dist/typeshed-fallback/stdlib/pwd.pyi +60 -10
- package/dist/typeshed-fallback/stdlib/pyexpat/__init__.pyi +61 -12
- package/dist/typeshed-fallback/stdlib/readline.pyi +184 -27
- package/dist/typeshed-fallback/stdlib/resource.pyi +56 -16
- package/dist/typeshed-fallback/stdlib/select.pyi +97 -5
- package/dist/typeshed-fallback/stdlib/spwd.pyi +60 -11
- package/dist/typeshed-fallback/stdlib/sys/__init__.pyi +386 -48
- package/dist/typeshed-fallback/stdlib/syslog.pyi +27 -7
- package/dist/typeshed-fallback/stdlib/termios.pyi +88 -8
- package/dist/typeshed-fallback/stdlib/time.pyi +314 -37
- package/dist/typeshed-fallback/stdlib/unicodedata.pyi +264 -34
- package/dist/typeshed-fallback/stdlib/winreg.pyi +172 -132
- package/dist/typeshed-fallback/stdlib/zlib.pyi +108 -7
- package/package.json +1 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Implementation module for socket operations.
|
|
3
|
+
|
|
4
|
+
See the socket module for documentation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
1
7
|
import sys
|
|
2
8
|
from _typeshed import ReadableBuffer, WriteableBuffer
|
|
3
9
|
from collections.abc import Iterable
|
|
@@ -681,14 +687,71 @@ else:
|
|
|
681
687
|
# ===== Classes =====
|
|
682
688
|
|
|
683
689
|
class socket:
|
|
690
|
+
"""
|
|
691
|
+
socket(family=AF_INET, type=SOCK_STREAM, proto=0) -> socket object
|
|
692
|
+
socket(family=-1, type=-1, proto=-1, fileno=None) -> socket object
|
|
693
|
+
|
|
694
|
+
Open a socket of the given type. The family argument specifies the
|
|
695
|
+
address family; it defaults to AF_INET. The type argument specifies
|
|
696
|
+
whether this is a stream (SOCK_STREAM, this is the default)
|
|
697
|
+
or datagram (SOCK_DGRAM) socket. The protocol argument defaults to 0,
|
|
698
|
+
specifying the default protocol. Keyword arguments are accepted.
|
|
699
|
+
The socket is created as non-inheritable.
|
|
700
|
+
|
|
701
|
+
When a fileno is passed in, family, type and proto are auto-detected,
|
|
702
|
+
unless they are explicitly set.
|
|
703
|
+
|
|
704
|
+
A socket object represents one endpoint of a network connection.
|
|
705
|
+
|
|
706
|
+
Methods of socket objects (keyword arguments not allowed):
|
|
707
|
+
|
|
708
|
+
_accept() -- accept connection, returning new socket fd and client address
|
|
709
|
+
bind(addr) -- bind the socket to a local address
|
|
710
|
+
close() -- close the socket
|
|
711
|
+
connect(addr) -- connect the socket to a remote address
|
|
712
|
+
connect_ex(addr) -- connect, return an error code instead of an exception
|
|
713
|
+
dup() -- return a new socket fd duplicated from fileno()
|
|
714
|
+
fileno() -- return underlying file descriptor
|
|
715
|
+
getpeername() -- return remote address [*]
|
|
716
|
+
getsockname() -- return local address
|
|
717
|
+
getsockopt(level, optname[, buflen]) -- get socket options
|
|
718
|
+
gettimeout() -- return timeout or None
|
|
719
|
+
listen([n]) -- start listening for incoming connections
|
|
720
|
+
recv(buflen[, flags]) -- receive data
|
|
721
|
+
recv_into(buffer[, nbytes[, flags]]) -- receive data (into a buffer)
|
|
722
|
+
recvfrom(buflen[, flags]) -- receive data and sender's address
|
|
723
|
+
recvfrom_into(buffer[, nbytes, [, flags])
|
|
724
|
+
-- receive data and sender's address (into a buffer)
|
|
725
|
+
sendall(data[, flags]) -- send all data
|
|
726
|
+
send(data[, flags]) -- send data, may not send all of it
|
|
727
|
+
sendto(data[, flags], addr) -- send data to a given address
|
|
728
|
+
setblocking(0 | 1) -- set or clear the blocking I/O flag
|
|
729
|
+
getblocking() -- return True if socket is blocking, False if non-blocking
|
|
730
|
+
setsockopt(level, optname, value[, optlen]) -- set socket options
|
|
731
|
+
settimeout(None | float) -- set or clear the timeout
|
|
732
|
+
shutdown(how) -- shut down traffic in one or both directions
|
|
733
|
+
if_nameindex() -- return all network interface indices and names
|
|
734
|
+
if_nametoindex(name) -- return the corresponding interface index
|
|
735
|
+
if_indextoname(index) -- return the corresponding interface name
|
|
736
|
+
|
|
737
|
+
[*] not available on all platforms!
|
|
738
|
+
"""
|
|
684
739
|
@property
|
|
685
|
-
def family(self) -> int:
|
|
740
|
+
def family(self) -> int:
|
|
741
|
+
"""the socket family"""
|
|
742
|
+
...
|
|
686
743
|
@property
|
|
687
|
-
def type(self) -> int:
|
|
744
|
+
def type(self) -> int:
|
|
745
|
+
"""the socket type"""
|
|
746
|
+
...
|
|
688
747
|
@property
|
|
689
|
-
def proto(self) -> int:
|
|
748
|
+
def proto(self) -> int:
|
|
749
|
+
"""the socket protocol"""
|
|
750
|
+
...
|
|
690
751
|
@property
|
|
691
|
-
def timeout(self) -> float | None:
|
|
752
|
+
def timeout(self) -> float | None:
|
|
753
|
+
"""the socket timeout"""
|
|
754
|
+
...
|
|
692
755
|
if sys.platform == "win32":
|
|
693
756
|
def __init__(
|
|
694
757
|
self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | bytes | None = ...
|
|
@@ -696,40 +759,263 @@ class socket:
|
|
|
696
759
|
else:
|
|
697
760
|
def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | None = ...) -> None: ...
|
|
698
761
|
|
|
699
|
-
def bind(self, address: _Address, /) -> None:
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
762
|
+
def bind(self, address: _Address, /) -> None:
|
|
763
|
+
"""
|
|
764
|
+
bind(address)
|
|
765
|
+
|
|
766
|
+
Bind the socket to a local address. For IP sockets, the address is a
|
|
767
|
+
pair (host, port); the host must refer to the local host. For raw packet
|
|
768
|
+
sockets the address is a tuple (ifname, proto [,pkttype [,hatype [,addr]]])
|
|
769
|
+
"""
|
|
770
|
+
...
|
|
771
|
+
def close(self) -> None:
|
|
772
|
+
"""
|
|
773
|
+
close()
|
|
774
|
+
|
|
775
|
+
Close the socket. It cannot be used after this call.
|
|
776
|
+
"""
|
|
777
|
+
...
|
|
778
|
+
def connect(self, address: _Address, /) -> None:
|
|
779
|
+
"""
|
|
780
|
+
connect(address)
|
|
781
|
+
|
|
782
|
+
Connect the socket to a remote address. For IP sockets, the address
|
|
783
|
+
is a pair (host, port).
|
|
784
|
+
"""
|
|
785
|
+
...
|
|
786
|
+
def connect_ex(self, address: _Address, /) -> int:
|
|
787
|
+
"""
|
|
788
|
+
connect_ex(address) -> errno
|
|
789
|
+
|
|
790
|
+
This is like connect(address), but returns an error code (the errno value)
|
|
791
|
+
instead of raising an exception when an error occurs.
|
|
792
|
+
"""
|
|
793
|
+
...
|
|
794
|
+
def detach(self) -> int:
|
|
795
|
+
"""
|
|
796
|
+
detach()
|
|
797
|
+
|
|
798
|
+
Close the socket object without closing the underlying file descriptor.
|
|
799
|
+
The object cannot be used after this call, but the file descriptor
|
|
800
|
+
can be reused for other purposes. The file descriptor is returned.
|
|
801
|
+
"""
|
|
802
|
+
...
|
|
803
|
+
def fileno(self) -> int:
|
|
804
|
+
"""
|
|
805
|
+
fileno() -> integer
|
|
806
|
+
|
|
807
|
+
Return the integer file descriptor of the socket.
|
|
808
|
+
"""
|
|
809
|
+
...
|
|
810
|
+
def getpeername(self) -> _RetAddress:
|
|
811
|
+
"""
|
|
812
|
+
getpeername() -> address info
|
|
813
|
+
|
|
814
|
+
Return the address of the remote endpoint. For IP sockets, the address
|
|
815
|
+
info is a pair (hostaddr, port).
|
|
816
|
+
"""
|
|
817
|
+
...
|
|
818
|
+
def getsockname(self) -> _RetAddress:
|
|
819
|
+
"""
|
|
820
|
+
getsockname() -> address info
|
|
821
|
+
|
|
822
|
+
Return the address of the local endpoint. The format depends on the
|
|
823
|
+
address family. For IPv4 sockets, the address info is a pair
|
|
824
|
+
(hostaddr, port).
|
|
825
|
+
"""
|
|
826
|
+
...
|
|
707
827
|
@overload
|
|
708
|
-
def getsockopt(self, level: int, optname: int, /) -> int:
|
|
828
|
+
def getsockopt(self, level: int, optname: int, /) -> int:
|
|
829
|
+
"""
|
|
830
|
+
getsockopt(level, option[, buffersize]) -> value
|
|
831
|
+
|
|
832
|
+
Get a socket option. See the Unix manual for level and option.
|
|
833
|
+
If a nonzero buffersize argument is given, the return value is a
|
|
834
|
+
string of that length; otherwise it is an integer.
|
|
835
|
+
"""
|
|
836
|
+
...
|
|
709
837
|
@overload
|
|
710
|
-
def getsockopt(self, level: int, optname: int, buflen: int, /) -> bytes:
|
|
711
|
-
|
|
712
|
-
|
|
838
|
+
def getsockopt(self, level: int, optname: int, buflen: int, /) -> bytes:
|
|
839
|
+
"""
|
|
840
|
+
getsockopt(level, option[, buffersize]) -> value
|
|
841
|
+
|
|
842
|
+
Get a socket option. See the Unix manual for level and option.
|
|
843
|
+
If a nonzero buffersize argument is given, the return value is a
|
|
844
|
+
string of that length; otherwise it is an integer.
|
|
845
|
+
"""
|
|
846
|
+
...
|
|
847
|
+
def getblocking(self) -> bool:
|
|
848
|
+
"""
|
|
849
|
+
getblocking()
|
|
850
|
+
|
|
851
|
+
Returns True if socket is in blocking mode, or False if it
|
|
852
|
+
is in non-blocking mode.
|
|
853
|
+
"""
|
|
854
|
+
...
|
|
855
|
+
def gettimeout(self) -> float | None:
|
|
856
|
+
"""
|
|
857
|
+
gettimeout() -> timeout
|
|
858
|
+
|
|
859
|
+
Returns the timeout in seconds (float) associated with socket
|
|
860
|
+
operations. A timeout of None indicates that timeouts on socket
|
|
861
|
+
operations are disabled.
|
|
862
|
+
"""
|
|
863
|
+
...
|
|
713
864
|
if sys.platform == "win32":
|
|
714
865
|
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool, /) -> None: ...
|
|
715
866
|
|
|
716
|
-
def listen(self, backlog: int = ..., /) -> None:
|
|
717
|
-
|
|
718
|
-
|
|
867
|
+
def listen(self, backlog: int = ..., /) -> None:
|
|
868
|
+
"""
|
|
869
|
+
listen([backlog])
|
|
870
|
+
|
|
871
|
+
Enable a server to accept connections. If backlog is specified, it must be
|
|
872
|
+
at least 0 (if it is lower, it is set to 0); it specifies the number of
|
|
873
|
+
unaccepted connections that the system will allow before refusing new
|
|
874
|
+
connections. If not specified, a default reasonable value is chosen.
|
|
875
|
+
"""
|
|
876
|
+
...
|
|
877
|
+
def recv(self, bufsize: int, flags: int = ..., /) -> bytes:
|
|
878
|
+
"""
|
|
879
|
+
recv(buffersize[, flags]) -> data
|
|
880
|
+
|
|
881
|
+
Receive up to buffersize bytes from the socket. For the optional flags
|
|
882
|
+
argument, see the Unix manual. When no data is available, block until
|
|
883
|
+
at least one byte is available or until the remote end is closed. When
|
|
884
|
+
the remote end is closed and all data is read, return the empty string.
|
|
885
|
+
"""
|
|
886
|
+
...
|
|
887
|
+
def recvfrom(self, bufsize: int, flags: int = ..., /) -> tuple[bytes, _RetAddress]:
|
|
888
|
+
"""
|
|
889
|
+
recvfrom(buffersize[, flags]) -> (data, address info)
|
|
890
|
+
|
|
891
|
+
Like recv(buffersize, flags) but also return the sender's address info.
|
|
892
|
+
"""
|
|
893
|
+
...
|
|
719
894
|
if sys.platform != "win32":
|
|
720
|
-
def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]:
|
|
895
|
+
def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]:
|
|
896
|
+
"""
|
|
897
|
+
recvmsg(bufsize[, ancbufsize[, flags]]) -> (data, ancdata, msg_flags, address)
|
|
898
|
+
|
|
899
|
+
Receive normal data (up to bufsize bytes) and ancillary data from the
|
|
900
|
+
socket. The ancbufsize argument sets the size in bytes of the
|
|
901
|
+
internal buffer used to receive the ancillary data; it defaults to 0,
|
|
902
|
+
meaning that no ancillary data will be received. Appropriate buffer
|
|
903
|
+
sizes for ancillary data can be calculated using CMSG_SPACE() or
|
|
904
|
+
CMSG_LEN(), and items which do not fit into the buffer might be
|
|
905
|
+
truncated or discarded. The flags argument defaults to 0 and has the
|
|
906
|
+
same meaning as for recv().
|
|
907
|
+
|
|
908
|
+
The return value is a 4-tuple: (data, ancdata, msg_flags, address).
|
|
909
|
+
The data item is a bytes object holding the non-ancillary data
|
|
910
|
+
received. The ancdata item is a list of zero or more tuples
|
|
911
|
+
(cmsg_level, cmsg_type, cmsg_data) representing the ancillary data
|
|
912
|
+
(control messages) received: cmsg_level and cmsg_type are integers
|
|
913
|
+
specifying the protocol level and protocol-specific type respectively,
|
|
914
|
+
and cmsg_data is a bytes object holding the associated data. The
|
|
915
|
+
msg_flags item is the bitwise OR of various flags indicating
|
|
916
|
+
conditions on the received message; see your system documentation for
|
|
917
|
+
details. If the receiving socket is unconnected, address is the
|
|
918
|
+
address of the sending socket, if available; otherwise, its value is
|
|
919
|
+
unspecified.
|
|
920
|
+
|
|
921
|
+
If recvmsg() raises an exception after the system call returns, it
|
|
922
|
+
will first attempt to close any file descriptors received via the
|
|
923
|
+
SCM_RIGHTS mechanism.
|
|
924
|
+
"""
|
|
925
|
+
...
|
|
721
926
|
def recvmsg_into(
|
|
722
927
|
self, buffers: Iterable[WriteableBuffer], ancbufsize: int = ..., flags: int = ..., /
|
|
723
|
-
) -> tuple[int, list[_CMSG], int, Any]:
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
928
|
+
) -> tuple[int, list[_CMSG], int, Any]:
|
|
929
|
+
"""
|
|
930
|
+
recvmsg_into(buffers[, ancbufsize[, flags]]) -> (nbytes, ancdata, msg_flags, address)
|
|
931
|
+
|
|
932
|
+
Receive normal data and ancillary data from the socket, scattering the
|
|
933
|
+
non-ancillary data into a series of buffers. The buffers argument
|
|
934
|
+
must be an iterable of objects that export writable buffers
|
|
935
|
+
(e.g. bytearray objects); these will be filled with successive chunks
|
|
936
|
+
of the non-ancillary data until it has all been written or there are
|
|
937
|
+
no more buffers. The ancbufsize argument sets the size in bytes of
|
|
938
|
+
the internal buffer used to receive the ancillary data; it defaults to
|
|
939
|
+
0, meaning that no ancillary data will be received. Appropriate
|
|
940
|
+
buffer sizes for ancillary data can be calculated using CMSG_SPACE()
|
|
941
|
+
or CMSG_LEN(), and items which do not fit into the buffer might be
|
|
942
|
+
truncated or discarded. The flags argument defaults to 0 and has the
|
|
943
|
+
same meaning as for recv().
|
|
944
|
+
|
|
945
|
+
The return value is a 4-tuple: (nbytes, ancdata, msg_flags, address).
|
|
946
|
+
The nbytes item is the total number of bytes of non-ancillary data
|
|
947
|
+
written into the buffers. The ancdata item is a list of zero or more
|
|
948
|
+
tuples (cmsg_level, cmsg_type, cmsg_data) representing the ancillary
|
|
949
|
+
data (control messages) received: cmsg_level and cmsg_type are
|
|
950
|
+
integers specifying the protocol level and protocol-specific type
|
|
951
|
+
respectively, and cmsg_data is a bytes object holding the associated
|
|
952
|
+
data. The msg_flags item is the bitwise OR of various flags
|
|
953
|
+
indicating conditions on the received message; see your system
|
|
954
|
+
documentation for details. If the receiving socket is unconnected,
|
|
955
|
+
address is the address of the sending socket, if available; otherwise,
|
|
956
|
+
its value is unspecified.
|
|
957
|
+
|
|
958
|
+
If recvmsg_into() raises an exception after the system call returns,
|
|
959
|
+
it will first attempt to close any file descriptors received via the
|
|
960
|
+
SCM_RIGHTS mechanism.
|
|
961
|
+
"""
|
|
962
|
+
...
|
|
963
|
+
|
|
964
|
+
def recvfrom_into(self, buffer: WriteableBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]:
|
|
965
|
+
"""
|
|
966
|
+
recvfrom_into(buffer[, nbytes[, flags]]) -> (nbytes, address info)
|
|
967
|
+
|
|
968
|
+
Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's address info.
|
|
969
|
+
"""
|
|
970
|
+
...
|
|
971
|
+
def recv_into(self, buffer: WriteableBuffer, nbytes: int = ..., flags: int = ...) -> int:
|
|
972
|
+
"""
|
|
973
|
+
recv_into(buffer, [nbytes[, flags]]) -> nbytes_read
|
|
974
|
+
|
|
975
|
+
A version of recv() that stores its data into a buffer rather than creating
|
|
976
|
+
a new string. Receive up to buffersize bytes from the socket. If buffersize
|
|
977
|
+
is not specified (or 0), receive up to the size available in the given buffer.
|
|
978
|
+
|
|
979
|
+
See recv() for documentation about the flags.
|
|
980
|
+
"""
|
|
981
|
+
...
|
|
982
|
+
def send(self, data: ReadableBuffer, flags: int = ..., /) -> int:
|
|
983
|
+
"""
|
|
984
|
+
send(data[, flags]) -> count
|
|
985
|
+
|
|
986
|
+
Send a data string to the socket. For the optional flags
|
|
987
|
+
argument, see the Unix manual. Return the number of bytes
|
|
988
|
+
sent; this may be less than len(data) if the network is busy.
|
|
989
|
+
"""
|
|
990
|
+
...
|
|
991
|
+
def sendall(self, data: ReadableBuffer, flags: int = ..., /) -> None:
|
|
992
|
+
"""
|
|
993
|
+
sendall(data[, flags])
|
|
994
|
+
|
|
995
|
+
Send a data string to the socket. For the optional flags
|
|
996
|
+
argument, see the Unix manual. This calls send() repeatedly
|
|
997
|
+
until all data is sent. If an error occurs, it's impossible
|
|
998
|
+
to tell how much data has been sent.
|
|
999
|
+
"""
|
|
1000
|
+
...
|
|
729
1001
|
@overload
|
|
730
|
-
def sendto(self, data: ReadableBuffer, address: _Address, /) -> int:
|
|
1002
|
+
def sendto(self, data: ReadableBuffer, address: _Address, /) -> int:
|
|
1003
|
+
"""
|
|
1004
|
+
sendto(data[, flags], address) -> count
|
|
1005
|
+
|
|
1006
|
+
Like send(data, flags) but allows specifying the destination address.
|
|
1007
|
+
For IP sockets, the address is a pair (hostaddr, port).
|
|
1008
|
+
"""
|
|
1009
|
+
...
|
|
731
1010
|
@overload
|
|
732
|
-
def sendto(self, data: ReadableBuffer, flags: int, address: _Address, /) -> int:
|
|
1011
|
+
def sendto(self, data: ReadableBuffer, flags: int, address: _Address, /) -> int:
|
|
1012
|
+
"""
|
|
1013
|
+
sendto(data[, flags], address) -> count
|
|
1014
|
+
|
|
1015
|
+
Like send(data, flags) but allows specifying the destination address.
|
|
1016
|
+
For IP sockets, the address is a pair (hostaddr, port).
|
|
1017
|
+
"""
|
|
1018
|
+
...
|
|
733
1019
|
if sys.platform != "win32":
|
|
734
1020
|
def sendmsg(
|
|
735
1021
|
self,
|
|
@@ -738,29 +1024,105 @@ class socket:
|
|
|
738
1024
|
flags: int = ...,
|
|
739
1025
|
address: _Address | None = ...,
|
|
740
1026
|
/,
|
|
741
|
-
) -> int:
|
|
1027
|
+
) -> int:
|
|
1028
|
+
"""
|
|
1029
|
+
sendmsg(buffers[, ancdata[, flags[, address]]]) -> count
|
|
1030
|
+
|
|
1031
|
+
Send normal and ancillary data to the socket, gathering the
|
|
1032
|
+
non-ancillary data from a series of buffers and concatenating it into
|
|
1033
|
+
a single message. The buffers argument specifies the non-ancillary
|
|
1034
|
+
data as an iterable of bytes-like objects (e.g. bytes objects).
|
|
1035
|
+
The ancdata argument specifies the ancillary data (control messages)
|
|
1036
|
+
as an iterable of zero or more tuples (cmsg_level, cmsg_type,
|
|
1037
|
+
cmsg_data), where cmsg_level and cmsg_type are integers specifying the
|
|
1038
|
+
protocol level and protocol-specific type respectively, and cmsg_data
|
|
1039
|
+
is a bytes-like object holding the associated data. The flags
|
|
1040
|
+
argument defaults to 0 and has the same meaning as for send(). If
|
|
1041
|
+
address is supplied and not None, it sets a destination address for
|
|
1042
|
+
the message. The return value is the number of bytes of non-ancillary
|
|
1043
|
+
data sent.
|
|
1044
|
+
"""
|
|
1045
|
+
...
|
|
742
1046
|
if sys.platform == "linux":
|
|
743
1047
|
def sendmsg_afalg(
|
|
744
1048
|
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
|
745
1049
|
) -> int: ...
|
|
746
1050
|
|
|
747
|
-
def setblocking(self, flag: bool, /) -> None:
|
|
748
|
-
|
|
1051
|
+
def setblocking(self, flag: bool, /) -> None:
|
|
1052
|
+
"""
|
|
1053
|
+
setblocking(flag)
|
|
1054
|
+
|
|
1055
|
+
Set the socket to blocking (flag is true) or non-blocking (false).
|
|
1056
|
+
setblocking(True) is equivalent to settimeout(None);
|
|
1057
|
+
setblocking(False) is equivalent to settimeout(0.0).
|
|
1058
|
+
"""
|
|
1059
|
+
...
|
|
1060
|
+
def settimeout(self, value: float | None, /) -> None:
|
|
1061
|
+
"""
|
|
1062
|
+
settimeout(timeout)
|
|
1063
|
+
|
|
1064
|
+
Set a timeout on socket operations. 'timeout' can be a float,
|
|
1065
|
+
giving in seconds, or None. Setting a timeout of None disables
|
|
1066
|
+
the timeout feature and is equivalent to setblocking(1).
|
|
1067
|
+
Setting a timeout of zero is the same as setblocking(0).
|
|
1068
|
+
"""
|
|
1069
|
+
...
|
|
749
1070
|
@overload
|
|
750
|
-
def setsockopt(self, level: int, optname: int, value: int | ReadableBuffer, /) -> None:
|
|
1071
|
+
def setsockopt(self, level: int, optname: int, value: int | ReadableBuffer, /) -> None:
|
|
1072
|
+
"""
|
|
1073
|
+
setsockopt(level, option, value: int)
|
|
1074
|
+
setsockopt(level, option, value: buffer)
|
|
1075
|
+
setsockopt(level, option, None, optlen: int)
|
|
1076
|
+
|
|
1077
|
+
Set a socket option. See the Unix manual for level and option.
|
|
1078
|
+
The value argument can either be an integer, a string buffer, or
|
|
1079
|
+
None, optlen.
|
|
1080
|
+
"""
|
|
1081
|
+
...
|
|
751
1082
|
@overload
|
|
752
|
-
def setsockopt(self, level: int, optname: int, value: None, optlen: int, /) -> None:
|
|
1083
|
+
def setsockopt(self, level: int, optname: int, value: None, optlen: int, /) -> None:
|
|
1084
|
+
"""
|
|
1085
|
+
setsockopt(level, option, value: int)
|
|
1086
|
+
setsockopt(level, option, value: buffer)
|
|
1087
|
+
setsockopt(level, option, None, optlen: int)
|
|
1088
|
+
|
|
1089
|
+
Set a socket option. See the Unix manual for level and option.
|
|
1090
|
+
The value argument can either be an integer, a string buffer, or
|
|
1091
|
+
None, optlen.
|
|
1092
|
+
"""
|
|
1093
|
+
...
|
|
753
1094
|
if sys.platform == "win32":
|
|
754
1095
|
def share(self, process_id: int, /) -> bytes: ...
|
|
755
1096
|
|
|
756
|
-
def shutdown(self, how: int, /) -> None:
|
|
1097
|
+
def shutdown(self, how: int, /) -> None:
|
|
1098
|
+
"""
|
|
1099
|
+
shutdown(flag)
|
|
1100
|
+
|
|
1101
|
+
Shut down the reading side of the socket (flag == SHUT_RD), the writing side
|
|
1102
|
+
of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).
|
|
1103
|
+
"""
|
|
1104
|
+
...
|
|
757
1105
|
|
|
758
1106
|
SocketType = socket
|
|
759
1107
|
|
|
760
1108
|
# ===== Functions =====
|
|
761
1109
|
|
|
762
|
-
def close(fd: SupportsIndex, /) -> None:
|
|
763
|
-
|
|
1110
|
+
def close(fd: SupportsIndex, /) -> None:
|
|
1111
|
+
"""
|
|
1112
|
+
close(integer) -> None
|
|
1113
|
+
|
|
1114
|
+
Close an integer socket file descriptor. This is like os.close(), but for
|
|
1115
|
+
sockets; on some platforms os.close() won't work for socket file descriptors.
|
|
1116
|
+
"""
|
|
1117
|
+
...
|
|
1118
|
+
def dup(fd: SupportsIndex, /) -> int:
|
|
1119
|
+
"""
|
|
1120
|
+
dup(integer) -> integer
|
|
1121
|
+
|
|
1122
|
+
Duplicate an integer socket file descriptor. This is like os.dup(), but for
|
|
1123
|
+
sockets; on some platforms os.dup() won't work for socket file descriptors.
|
|
1124
|
+
"""
|
|
1125
|
+
...
|
|
764
1126
|
|
|
765
1127
|
# the 5th tuple item is an address
|
|
766
1128
|
def getaddrinfo(
|
|
@@ -770,34 +1132,227 @@ def getaddrinfo(
|
|
|
770
1132
|
type: int = ...,
|
|
771
1133
|
proto: int = ...,
|
|
772
1134
|
flags: int = ...,
|
|
773
|
-
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]:
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
def
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
def
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
1135
|
+
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]:
|
|
1136
|
+
"""
|
|
1137
|
+
getaddrinfo(host, port [, family, type, proto, flags])
|
|
1138
|
+
-> list of (family, type, proto, canonname, sockaddr)
|
|
1139
|
+
|
|
1140
|
+
Resolve host and port into addrinfo struct.
|
|
1141
|
+
"""
|
|
1142
|
+
...
|
|
1143
|
+
def gethostbyname(hostname: str, /) -> str:
|
|
1144
|
+
"""
|
|
1145
|
+
gethostbyname(host) -> address
|
|
1146
|
+
|
|
1147
|
+
Return the IP address (a string of the form '255.255.255.255') for a host.
|
|
1148
|
+
"""
|
|
1149
|
+
...
|
|
1150
|
+
def gethostbyname_ex(hostname: str, /) -> tuple[str, list[str], list[str]]:
|
|
1151
|
+
"""
|
|
1152
|
+
gethostbyname_ex(host) -> (name, aliaslist, addresslist)
|
|
1153
|
+
|
|
1154
|
+
Return the true host name, a list of aliases, and a list of IP addresses,
|
|
1155
|
+
for a host. The host argument is a string giving a host name or IP number.
|
|
1156
|
+
"""
|
|
1157
|
+
...
|
|
1158
|
+
def gethostname() -> str:
|
|
1159
|
+
"""
|
|
1160
|
+
gethostname() -> string
|
|
1161
|
+
|
|
1162
|
+
Return the current host name.
|
|
1163
|
+
"""
|
|
1164
|
+
...
|
|
1165
|
+
def gethostbyaddr(ip_address: str, /) -> tuple[str, list[str], list[str]]:
|
|
1166
|
+
"""
|
|
1167
|
+
gethostbyaddr(host) -> (name, aliaslist, addresslist)
|
|
1168
|
+
|
|
1169
|
+
Return the true host name, a list of aliases, and a list of IP addresses,
|
|
1170
|
+
for a host. The host argument is a string giving a host name or IP number.
|
|
1171
|
+
"""
|
|
1172
|
+
...
|
|
1173
|
+
def getnameinfo(sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int, /) -> tuple[str, str]:
|
|
1174
|
+
"""
|
|
1175
|
+
getnameinfo(sockaddr, flags) --> (host, port)
|
|
1176
|
+
|
|
1177
|
+
Get host and port for a sockaddr.
|
|
1178
|
+
"""
|
|
1179
|
+
...
|
|
1180
|
+
def getprotobyname(protocolname: str, /) -> int:
|
|
1181
|
+
"""
|
|
1182
|
+
getprotobyname(name) -> integer
|
|
1183
|
+
|
|
1184
|
+
Return the protocol number for the named protocol. (Rarely used.)
|
|
1185
|
+
"""
|
|
1186
|
+
...
|
|
1187
|
+
def getservbyname(servicename: str, protocolname: str = ..., /) -> int:
|
|
1188
|
+
"""
|
|
1189
|
+
getservbyname(servicename[, protocolname]) -> integer
|
|
1190
|
+
|
|
1191
|
+
Return a port number from a service name and protocol name.
|
|
1192
|
+
The optional protocol name, if given, should be 'tcp' or 'udp',
|
|
1193
|
+
otherwise any protocol will match.
|
|
1194
|
+
"""
|
|
1195
|
+
...
|
|
1196
|
+
def getservbyport(port: int, protocolname: str = ..., /) -> str:
|
|
1197
|
+
"""
|
|
1198
|
+
getservbyport(port[, protocolname]) -> string
|
|
1199
|
+
|
|
1200
|
+
Return the service name from a port number and protocol name.
|
|
1201
|
+
The optional protocol name, if given, should be 'tcp' or 'udp',
|
|
1202
|
+
otherwise any protocol will match.
|
|
1203
|
+
"""
|
|
1204
|
+
...
|
|
1205
|
+
def ntohl(x: int, /) -> int:
|
|
1206
|
+
"""
|
|
1207
|
+
ntohl(integer) -> integer
|
|
1208
|
+
|
|
1209
|
+
Convert a 32-bit integer from network to host byte order.
|
|
1210
|
+
"""
|
|
1211
|
+
...
|
|
1212
|
+
def ntohs(x: int, /) -> int:
|
|
1213
|
+
"""
|
|
1214
|
+
ntohs(integer) -> integer
|
|
1215
|
+
|
|
1216
|
+
Convert a 16-bit unsigned integer from network to host byte order.
|
|
1217
|
+
Note that in case the received integer does not fit in 16-bit unsigned
|
|
1218
|
+
integer, but does fit in a positive C int, it is silently truncated to
|
|
1219
|
+
16-bit unsigned integer.
|
|
1220
|
+
However, this silent truncation feature is deprecated, and will raise an
|
|
1221
|
+
exception in future versions of Python.
|
|
1222
|
+
"""
|
|
1223
|
+
...
|
|
1224
|
+
def htonl(x: int, /) -> int:
|
|
1225
|
+
"""
|
|
1226
|
+
htonl(integer) -> integer
|
|
1227
|
+
|
|
1228
|
+
Convert a 32-bit integer from host to network byte order.
|
|
1229
|
+
"""
|
|
1230
|
+
...
|
|
1231
|
+
def htons(x: int, /) -> int:
|
|
1232
|
+
"""
|
|
1233
|
+
htons(integer) -> integer
|
|
1234
|
+
|
|
1235
|
+
Convert a 16-bit unsigned integer from host to network byte order.
|
|
1236
|
+
Note that in case the received integer does not fit in 16-bit unsigned
|
|
1237
|
+
integer, but does fit in a positive C int, it is silently truncated to
|
|
1238
|
+
16-bit unsigned integer.
|
|
1239
|
+
However, this silent truncation feature is deprecated, and will raise an
|
|
1240
|
+
exception in future versions of Python.
|
|
1241
|
+
"""
|
|
1242
|
+
...
|
|
1243
|
+
def inet_aton(ip_addr: str, /) -> bytes:
|
|
1244
|
+
"""
|
|
1245
|
+
inet_aton(string) -> bytes giving packed 32-bit IP representation
|
|
1246
|
+
|
|
1247
|
+
Convert an IP address in string format (123.45.67.89) to the 32-bit packed
|
|
1248
|
+
binary format used in low-level network functions.
|
|
1249
|
+
"""
|
|
1250
|
+
...
|
|
1251
|
+
def inet_ntoa(packed_ip: ReadableBuffer, /) -> str:
|
|
1252
|
+
"""
|
|
1253
|
+
inet_ntoa(packed_ip) -> ip_address_string
|
|
1254
|
+
|
|
1255
|
+
Convert an IP address from 32-bit packed binary format to string format
|
|
1256
|
+
"""
|
|
1257
|
+
...
|
|
1258
|
+
def inet_pton(address_family: int, ip_string: str, /) -> bytes:
|
|
1259
|
+
"""
|
|
1260
|
+
inet_pton(af, ip) -> packed IP address string
|
|
1261
|
+
|
|
1262
|
+
Convert an IP address from string format to a packed string suitable
|
|
1263
|
+
for use with low-level network functions.
|
|
1264
|
+
"""
|
|
1265
|
+
...
|
|
1266
|
+
def inet_ntop(address_family: int, packed_ip: ReadableBuffer, /) -> str:
|
|
1267
|
+
"""
|
|
1268
|
+
inet_ntop(af, packed_ip) -> string formatted IP address
|
|
1269
|
+
|
|
1270
|
+
Convert a packed IP address of the given family to string format.
|
|
1271
|
+
"""
|
|
1272
|
+
...
|
|
1273
|
+
def getdefaulttimeout() -> float | None:
|
|
1274
|
+
"""
|
|
1275
|
+
getdefaulttimeout() -> timeout
|
|
1276
|
+
|
|
1277
|
+
Returns the default timeout in seconds (float) for new socket objects.
|
|
1278
|
+
A value of None indicates that new socket objects have no timeout.
|
|
1279
|
+
When the socket module is first imported, the default is None.
|
|
1280
|
+
"""
|
|
1281
|
+
...
|
|
1282
|
+
def setdefaulttimeout(timeout: float | None, /) -> None:
|
|
1283
|
+
"""
|
|
1284
|
+
setdefaulttimeout(timeout)
|
|
1285
|
+
|
|
1286
|
+
Set the default timeout in seconds (float) for new socket objects.
|
|
1287
|
+
A value of None indicates that new socket objects have no timeout.
|
|
1288
|
+
When the socket module is first imported, the default is None.
|
|
1289
|
+
"""
|
|
1290
|
+
...
|
|
792
1291
|
|
|
793
1292
|
if sys.platform != "win32":
|
|
794
|
-
def sethostname(name: str, /) -> None:
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
def
|
|
1293
|
+
def sethostname(name: str, /) -> None:
|
|
1294
|
+
"""
|
|
1295
|
+
sethostname(name)
|
|
1296
|
+
|
|
1297
|
+
Sets the hostname to name.
|
|
1298
|
+
"""
|
|
1299
|
+
...
|
|
1300
|
+
def CMSG_LEN(length: int, /) -> int:
|
|
1301
|
+
"""
|
|
1302
|
+
CMSG_LEN(length) -> control message length
|
|
1303
|
+
|
|
1304
|
+
Return the total length, without trailing padding, of an ancillary
|
|
1305
|
+
data item with associated data of the given length. This value can
|
|
1306
|
+
often be used as the buffer size for recvmsg() to receive a single
|
|
1307
|
+
item of ancillary data, but RFC 3542 requires portable applications to
|
|
1308
|
+
use CMSG_SPACE() and thus include space for padding, even when the
|
|
1309
|
+
item will be the last in the buffer. Raises OverflowError if length
|
|
1310
|
+
is outside the permissible range of values.
|
|
1311
|
+
"""
|
|
1312
|
+
...
|
|
1313
|
+
def CMSG_SPACE(length: int, /) -> int:
|
|
1314
|
+
"""
|
|
1315
|
+
CMSG_SPACE(length) -> buffer size
|
|
1316
|
+
|
|
1317
|
+
Return the buffer size needed for recvmsg() to receive an ancillary
|
|
1318
|
+
data item with associated data of the given length, along with any
|
|
1319
|
+
trailing padding. The buffer space needed to receive multiple items
|
|
1320
|
+
is the sum of the CMSG_SPACE() values for their associated data
|
|
1321
|
+
lengths. Raises OverflowError if length is outside the permissible
|
|
1322
|
+
range of values.
|
|
1323
|
+
"""
|
|
1324
|
+
...
|
|
1325
|
+
def socketpair(family: int = ..., type: int = ..., proto: int = ..., /) -> tuple[socket, socket]:
|
|
1326
|
+
"""
|
|
1327
|
+
socketpair([family[, type [, proto]]]) -> (socket object, socket object)
|
|
1328
|
+
|
|
1329
|
+
Create a pair of socket objects from the sockets returned by the platform
|
|
1330
|
+
socketpair() function.
|
|
1331
|
+
The arguments are the same as for socket() except the default family is
|
|
1332
|
+
AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
|
|
1333
|
+
"""
|
|
1334
|
+
...
|
|
1335
|
+
|
|
1336
|
+
def if_nameindex() -> list[tuple[int, str]]:
|
|
1337
|
+
"""
|
|
1338
|
+
if_nameindex()
|
|
1339
|
+
|
|
1340
|
+
Returns a list of network interface information (index, name) tuples.
|
|
1341
|
+
"""
|
|
1342
|
+
...
|
|
1343
|
+
def if_nametoindex(oname: str, /) -> int:
|
|
1344
|
+
"""
|
|
1345
|
+
if_nametoindex(if_name)
|
|
1346
|
+
|
|
1347
|
+
Returns the interface index corresponding to the interface name if_name.
|
|
1348
|
+
"""
|
|
1349
|
+
...
|
|
1350
|
+
def if_indextoname(index: int, /) -> str:
|
|
1351
|
+
"""
|
|
1352
|
+
if_indextoname(if_index)
|
|
1353
|
+
|
|
1354
|
+
Returns the interface name corresponding to the interface index if_index.
|
|
1355
|
+
"""
|
|
1356
|
+
...
|
|
802
1357
|
|
|
803
1358
|
CAPI: object
|