On this page
socket.close
Prev: socket.AddressFamily | Up: socket | Next: socket.create_connection
Rel: socket.AddressFamily, socket.create_connection, socket.create_server, socket.dup
Ref: docs.python.org — socket.close
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import close
Signature & Overview
socket.close(object, /)
Close an integer socket file descriptor. This is like os.close(), but for sockets; on some platforms os.close() won't work for socket file descriptors.
Usage
import socket
s1, s2 = socket.socketpair()
fd = s1.detach() # detach raw fd from s1
socket.close(fd)
s2.close()
Gotchas
- Closes a raw integer socket descriptor: For normal
socket.socketobjects, always usewith s:ors.close()instead.
REPL Inspect
from socket import close
help(close)
Linked from
- tuts/python3/stdlib_module/socket
- tuts/python3/stdlib_module/socket/AddressFamily
- tuts/python3/stdlib_module/socket/create_connection
- tuts/python3/stdlib_module/socket/create_server
- tuts/python3/stdlib_module/socket/dup
- tuts/python3/stdlib_module/socket/error
- tuts/python3/stdlib_module/socket/fromfd
- tuts/python3/stdlib_module/socket/gaierror
- tuts/python3/stdlib_module/socket/getaddrinfo
- tuts/python3/stdlib_module/socket/getdefaulttimeout
- tuts/python3/stdlib_module/socket/getfqdn
- tuts/python3/stdlib_module/socket/gethostbyaddr
- tuts/python3/stdlib_module/socket/gethostbyname
- tuts/python3/stdlib_module/socket/gethostbyname_ex
- tuts/python3/stdlib_module/socket/gethostname
- tuts/python3/stdlib_module/socket/getnameinfo
- tuts/python3/stdlib_module/socket/getprotobyname
- tuts/python3/stdlib_module/socket/getservbyname
- tuts/python3/stdlib_module/socket/getservbyport
- tuts/python3/stdlib_module/socket/has_dualstack_ipv6
- tuts/python3/stdlib_module/socket/herror
- tuts/python3/stdlib_module/socket/htonl
- tuts/python3/stdlib_module/socket/htons
- tuts/python3/stdlib_module/socket/if_indextoname
- tuts/python3/stdlib_module/socket/if_nameindex
- tuts/python3/stdlib_module/socket/if_nametoindex
- tuts/python3/stdlib_module/socket/inet_aton
- tuts/python3/stdlib_module/socket/inet_ntoa
- tuts/python3/stdlib_module/socket/inet_ntop
- tuts/python3/stdlib_module/socket/inet_pton
- tuts/python3/stdlib_module/socket/ntohl
- tuts/python3/stdlib_module/socket/ntohs
- tuts/python3/stdlib_module/socket/recv_fds
- tuts/python3/stdlib_module/socket/send_fds
- tuts/python3/stdlib_module/socket/setdefaulttimeout
- tuts/python3/stdlib_module/socket/sethostname
- tuts/python3/stdlib_module/socket/socket
- tuts/python3/stdlib_module/socket/SocketKind
- tuts/python3/stdlib_module/socket/socketpair
- tuts/python3/stdlib_module/socket/SocketType
- tuts/python3/stdlib_module/socket/timeout
Related notes
- tuts/python3/stdlib_module/socket/AddressFamily Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_connection Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_server Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/dup Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/socket Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/error links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/fromfd links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/gaierror links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/getaddrinfo links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/getdefaulttimeout links to this page; shared tags: #socket, #stdlib