Most viewed recipes tagged "networking"http://code.activestate.com/recipes/tags/networking/views/2017-03-05T11:00:27-08:00ActiveState Code Recipesreceive UDP broadcasts (Python)
2010-06-30T16:46:16-07:00matt studieyhttp://code.activestate.com/recipes/users/4174312/http://code.activestate.com/recipes/577278-receive-udp-broadcasts/
<p style="color: grey">
Python
recipe 577278
by <a href="/recipes/users/4174312/">matt studiey</a>
(<a href="/recipes/tags/broadcast/">broadcast</a>, <a href="/recipes/tags/networking/">networking</a>, <a href="/recipes/tags/udp/">udp</a>).
</p>
<p>simplest implementation I could achieve</p>
HTTPS httplib Client Connection with Certificate Validation (Python)
2011-01-18T18:30:45-08:00Marcelo Fernándezhttp://code.activestate.com/recipes/users/4173551/http://code.activestate.com/recipes/577548-https-httplib-client-connection-with-certificate-v/
<p style="color: grey">
Python
recipe 577548
by <a href="/recipes/users/4173551/">Marcelo Fernández</a>
(<a href="/recipes/tags/certificate/">certificate</a>, <a href="/recipes/tags/client/">client</a>, <a href="/recipes/tags/client_server/">client_server</a>, <a href="/recipes/tags/httplib/">httplib</a>, <a href="/recipes/tags/https/">https</a>, <a href="/recipes/tags/networking/">networking</a>, <a href="/recipes/tags/ssl/">ssl</a>, <a href="/recipes/tags/validation/">validation</a>).
</p>
<p>Despite httplib.HTTPSConnection lets the programmer specify the client's pair of certificates, it doesn't force the underlying SSL library to check the server certificate against the client keys (from the client point of view).</p>
<p>This class allows to force this check, to ensure the python client is connecting to the right server.</p>
Get MAC address of current interface in one line of code (Python)
2012-10-01T17:16:27-07:00Leonid Vasilyevhttp://code.activestate.com/recipes/users/4183776/http://code.activestate.com/recipes/578277-get-mac-address-of-current-interface-in-one-line-o/
<p style="color: grey">
Python
recipe 578277
by <a href="/recipes/users/4183776/">Leonid Vasilyev</a>
(<a href="/recipes/tags/networking/">networking</a>, <a href="/recipes/tags/oneliner/">oneliner</a>).
Revision 2.
</p>
<p>uuid.getnode represents current mac address as an integer,
this one-liner formats this number in a standard mac adress form (i.e. bytes splitted by :)</p>
Server supporting IPv4 and IPv6 (Python)
2017-03-05T11:00:27-08:00Giampaolo Rodolàhttp://code.activestate.com/recipes/users/4178764/http://code.activestate.com/recipes/578504-server-supporting-ipv4-and-ipv6/
<p style="color: grey">
Python
recipe 578504
by <a href="/recipes/users/4178764/">Giampaolo Rodolà</a>
(<a href="/recipes/tags/dualstack/">dualstack</a>, <a href="/recipes/tags/ipv4/">ipv4</a>, <a href="/recipes/tags/ipv6/">ipv6</a>, <a href="/recipes/tags/ipv6_v6only/">ipv6_v6only</a>, <a href="/recipes/tags/networking/">networking</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/socket/">socket</a>).
Revision 13.
</p>
<p>Utility functions to create a single server socket which able to listen on both IPv4 and IPv6. Inspired by:
<a href="http://bugs.python.org/issue17561" rel="nofollow">http://bugs.python.org/issue17561</a></p>
<p>Expected usage:</p>
<pre class="prettyprint"><code>>>> sock = create_server_sock(("", 8000))
>>> if not has_dual_stack(sock):
... sock.close()
... sock = MultipleSocketsListener([("0.0.0.0", 8000), ("::", 8000)])
>>>
</code></pre>
<p>From here on you have a socket which listens on port 8000, all interfaces, serving both IPv4 and IPv6. You can start accepting new connections as usual:</p>
<pre class="prettyprint"><code>>>> while True:
... conn, addr = sock.accept()
... # handle new connection
</code></pre>
<p>Supports UNIX, Windows, non-blocking sockets and socket timeouts.
Works with Python >= 2.6 and 3.X.</p>
EAP-MD5 802.1X Supplicant (Python)
2010-12-29T22:15:14-08:00Andrew Grigorevhttp://code.activestate.com/recipes/users/4172098/http://code.activestate.com/recipes/577523-eap-md5-8021x-supplicant/
<p style="color: grey">
Python
recipe 577523
by <a href="/recipes/users/4172098/">Andrew Grigorev</a>
(<a href="/recipes/tags/authentication/">authentication</a>, <a href="/recipes/tags/eap/">eap</a>, <a href="/recipes/tags/md5/">md5</a>, <a href="/recipes/tags/networking/">networking</a>).
</p>
<p>802.1X EAP protocol supplicant (see RFC3748), supporting only MD5-Challenge authentication type. Linux only.</p>
Serve PDF with Netius, a pure-Python network library, and xtopdf (Python)
2014-12-03T21:27:54-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578974-serve-pdf-with-netius-a-pure-python-network-librar/
<p style="color: grey">
Python
recipe 578974
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/client/">client</a>, <a href="/recipes/tags/client_server/">client_server</a>, <a href="/recipes/tags/networking/">networking</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/server/">server</a>).
</p>
<p>This recipe shows how to serve PDF from a server written using Netius, a pure-Python library, together with xtopdf, a Python toolkit for PDF creation. It is a proof-of-concept recipe, to show the essentials needed for the task, so it hard-codes the text content that is served as PDF, but the concepts shown can easily be extended to serve dynamically generated PDF content.</p>