<commit_before>\section{\module{socket} ---
         Low-level networking interface}

\declaremodule{builtin}{socket}
\modulesynopsis{Low-level networking interface.}


This module provides access to the BSD \emph{socket} interface.
It is available on all modern \UNIX{} systems, Windows, MacOS, BeOS,
OS/2, and probably additional platforms.  \note{Some behavior may be
platform dependent, since calls are made to the operating system socket APIs.}

For an introduction to socket programming (in C), see the following
papers: \citetitle{An Introductory 4.3BSD Interprocess Communication
Tutorial}, by <NAME> and \citetitle{An Advanced 4.3BSD
Interprocess Communication Tutorial}, by <NAME>.  Leffler et al,
both in the \citetitle{\UNIX{} Programmer's Manual, Supplementary Documents 1}
(sections PS1:7 and PS1:8).  The platform-specific reference material
for the various socket-related system calls are also a valuable source
of information on the details of socket semantics.  For \UNIX, refer
to the manual pages; for Windows, see the WinSock (or Winsock 2)
specification.
For IPv6-ready APIs, readers may want to refer to \rfc{2553} titled
\citetitle{Basic Socket Interface Extensions for IPv6}.

The Python interface is a straightforward transliteration of the
\UNIX{} system call and library interface for sockets to Python's
object-oriented style: the \function{socket()} function returns a
\dfn{socket object}\obindex{socket} whose methods implement the
various socket system calls.  Parameter types are somewhat
higher-level than in the C interface: as with \method{read()} and
\method{write()} operations on Python files, buffer allocation on
receive operations is automatic, and buffer length is implicit on send
operations.

Socket addresses are represented as follows:
A single string is used for the \constant{AF_UNIX} address family.
A pair \code{(\var{host}, \var{port})} is used for the
\constant{AF_INET} address family, where \var{host} is a string
representing either a hostname in Internet domain notation like
\code{'daring.cwi.nl'} or an IPv4 address like \code{'192.168.3.11'},
and \var{port} is an integral port number.
For \constant{AF_INET6} address family, a four-tuple
\code{(\var{host}, \var{port}, \var{flowinfo}, \var{scopeid})} is
used, where \var{flowinfo} and \var{scopeid} represents
\code{sin6_flowinfo} and \code{sin6_scope_id} member in
\constant{struct sockaddr_in6} in C.
For \module{socket} module methods, \var{flowinfo} and \var{scopeid}
can be omitted just for backward compatibility. Note, however,
omission of \var{scopeid} can cause problems in manipulating scoped
IPv6 addresses. Other address families are currently not supported.
The address format required by a particular socket object is
automatically selected based on the address family specified when the
socket object was created.

For IPv4 addresses, two special forms are accepted instead of a host
address: the empty string represents \constant{INADDR_ANY}, and the string
\code{'<broadcast>'} represents \constant{INADDR_BROADCAST}.
The behavior is not available for IPv6 for backward compatibility,
therefore, you may want to avoid these if you intend to support IPv6 with
your Python programs.

If you use a hostname in the \var{host} portion of IPv4/v6 socket
address, the program may show a nondeterministic behavior, as Python
uses the first address returned from the DNS resolution.  The socket
address will be resolved differently into an actual IPv4/v6 address,
depending on the results from DNS resolution and/or the host
configuration.  For deterministic behavior use a numeric address in
\var{host} portion.

\versionadded[2.5]{AF_NETLINK sockets are represented as 
pairs \code{\var{pid}, \var{groups}}.}

All errors raise exceptions.  The normal exceptions for invalid<commit_msg>Remove extra period at end.<commit_after>\section{\module{socket} ---
         Low-level networking interface}

\declaremodule{builtin}{socket}
\modulesynopsis{Low-level networking interface.}


This module provides access to the BSD \emph{socket} interface.
It is available on all modern \UNIX{} systems, Windows, MacOS, BeOS,
OS/2, and probably additional platforms.  \note{Some behavior may be
platform dependent, since calls are made to the operating system socket APIs.}

For an introduction to socket programming (in C), see the following
papers: \citetitle{An Introductory 4.3BSD Interprocess Communication
Tutorial}, by <NAME> and \citetitle{An Advanced 4.3BSD
Interprocess Communication Tutorial}, by <NAME>.  Leffler et al,
both in the \citetitle{\UNIX{} Programmer's Manual, Supplementary Documents 1}
(sections PS1:7 and PS1:8).  The platform-specific reference material
for the various socket-related system calls are also a valuable source
of information on the details of socket semantics.  For \UNIX, refer
to the manual pages; for Windows, see the WinSock (or Winsock 2)
specification.
For IPv6-ready APIs, readers may want to refer to \rfc{2553} titled
\citetitle{Basic Socket Interface Extensions for IPv6}.

The Python interface is a straightforward transliteration of the
\UNIX{} system call and library interface for sockets to Python's
object-oriented style: the \function{socket()} function returns a
\dfn{socket object}\obindex{socket} whose methods implement the
various socket system calls.  Parameter types are somewhat
higher-level than in the C interface: as with \method{read()} and
\method{write()} operations on Python files, buffer allocation on
receive operations is automatic, and buffer length is implicit on send
operations.

Socket addresses are represented as follows:
A single string is used for the \constant{AF_UNIX} address family.
A pair \code{(\var{host}, \var{port})} is used for the
\constant{AF_INET} address family, where \var{host} is a string
representing either a hostname in Internet domain notation like
\code{'daring.cwi.nl'} or an IPv4 address like \code{'192.168.3.11'},
and \var{port} is an integral port number.
For \constant{AF_INET6} address family, a four-tuple
\code{(\var{host}, \var{port}, \var{flowinfo}, \var{scopeid})} is
used, where \var{flowinfo} and \var{scopeid} represents
\code{sin6_flowinfo} and \code{sin6_scope_id} member in
\constant{struct sockaddr_in6} in C.
For \module{socket} module methods, \var{flowinfo} and \var{scopeid}
can be omitted just for backward compatibility. Note, however,
omission of \var{scopeid} can cause problems in manipulating scoped
IPv6 addresses. Other address families are currently not supported.
The address format required by a particular socket object is
automatically selected based on the address family specified when the
socket object was created.

For IPv4 addresses, two special forms are accepted instead of a host
address: the empty string represents \constant{INADDR_ANY}, and the string
\code{'<broadcast>'} represents \constant{INADDR_BROADCAST}.
The behavior is not available for IPv6 for backward compatibility,
therefore, you may want to avoid these if you intend to support IPv6 with
your Python programs.

If you use a hostname in the \var{host} portion of IPv4/v6 socket
address, the program may show a nondeterministic behavior, as Python
uses the first address returned from the DNS resolution.  The socket
address will be resolved differently into an actual IPv4/v6 address,
depending on the results from DNS resolution and/or the host
configuration.  For deterministic behavior use a numeric address in
\var{host} portion.

\versionadded[2.5]{AF_NETLINK sockets are represented as 
pairs \code{\var{pid}, \var{groups}}}

All errors raise exceptions.  The normal exceptions for invalid
{'fraction_non_alphanumeric': 0.07475409836065573, 'fraction_numerical': 0.010754098360655738, 'mean_word_length': 5.125301204819277, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '619229', 'n_tokens_mistral': 2108, 'n_tokens_neox': 2007, 'n_words': 985}