Latest recipes tagged "network"http://code.activestate.com/recipes/tags/network/new/2015-07-17T04:18:15-07:00ActiveState Code RecipesInstalled Modules (Perl)
2015-07-17T04:18:15-07:00Roger Mbiama Assogohttp://code.activestate.com/recipes/users/4178746/http://code.activestate.com/recipes/579084-installed-modules/
<p style="color: grey">
Perl
recipe 579084
by <a href="/recipes/users/4178746/">Roger Mbiama Assogo</a>
(<a href="/recipes/tags/application/">application</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/network/">network</a>).
</p>
<p>Additional Perl modules are installed on the server (aside from the standard libraries)
run from a web broswer.</p>
Wait for network service to appear (Python)
2014-11-06T07:29:12-08:00Mohammad Taha Jahangirhttp://code.activestate.com/recipes/users/4188847/http://code.activestate.com/recipes/578955-wait-for-network-service-to-appear/
<p style="color: grey">
Python
recipe 578955
by <a href="/recipes/users/4188847/">Mohammad Taha Jahangir</a>
(<a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/socket/">socket</a>).
</p>
<p>This script allows you to wait until specified port is opened on remote server. This can be useful in automation jobs - restarting server, wake on lan etc. It can also be used for monitoring distant service/site.</p>
<p>The main problem that this script solves is that you need to handle two different timeouts when opening probing socket, and it is not described in python documentation. See <a href="http://bugs.python.org/issue5293" rel="nofollow">http://bugs.python.org/issue5293</a> for more information.</p>
Teach your computer a few tricks (Python)
2014-09-11T06:25:14-07:00Alexander Pletzerhttp://code.activestate.com/recipes/users/4190754/http://code.activestate.com/recipes/578932-teach-your-computer-a-few-tricks/
<p style="color: grey">
Python
recipe 578932
by <a href="/recipes/users/4190754/">Alexander Pletzer</a>
(<a href="/recipes/tags/anl/">anl</a>, <a href="/recipes/tags/back/">back</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/neural/">neural</a>, <a href="/recipes/tags/propagation/">propagation</a>).
</p>
<p>Following is an artifical neural network program that takes any number of inputs and any number of hidden layers, and spits out an output. It applies back propagation with regularization to minimize the cost function. A gradient descent algorithm tries to find the minimum of the cost function in the landscape of weights. </p>
Print Directly from web application to POS/EPS thermal printer (PHP)
2014-09-01T14:55:56-07:00imam feriantohttp://code.activestate.com/recipes/users/633541/http://code.activestate.com/recipes/578925-print-directly-from-web-application-to-poseps-ther/
<p style="color: grey">
PHP
recipe 578925
by <a href="/recipes/users/633541/">imam ferianto</a>
(<a href="/recipes/tags/kasir/">kasir</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/over/">over</a>, <a href="/recipes/tags/php/">php</a>, <a href="/recipes/tags/pos/">pos</a>, <a href="/recipes/tags/printer/">printer</a>, <a href="/recipes/tags/tiketing/">tiketing</a>).
Revision 2.
</p>
<p>this php script will printout barcode label directly from the web by phpscript</p>
Read text data from the network port (Python)
2012-12-04T20:17:59-08:00anatoly techtonikhttp://code.activestate.com/recipes/users/4168147/http://code.activestate.com/recipes/578355-read-text-data-from-the-network-port/
<p style="color: grey">
Python
recipe 578355
by <a href="/recipes/users/4168147/">anatoly techtonik</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>Here is a way to wait for incoming text on some port and print it to the screen. This is the best technique I could come up with.</p>
WebSocket interface (Python)
2012-11-25T16:52:21-08:00Nick Farohttp://code.activestate.com/recipes/users/4184363/http://code.activestate.com/recipes/578348-websocket-interface/
<p style="color: grey">
Python
recipe 578348
by <a href="/recipes/users/4184363/">Nick Faro</a>
(<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/socket/">socket</a>, <a href="/recipes/tags/websocket/">websocket</a>).
Revision 2.
</p>
<p>This tries its best to be a replacement for the regular <code>socket</code> module.</p>
<p>It supports only sending and receiving but should be useful enough.</p>
<p>The only real difference should be that you can't specify the number of bytes is received, instead do</p>
<pre class="prettyprint"><code>for message in socket.recv():
print(message)
</code></pre>
<p>Revision 2:
Added proper message receiving. Previously it just requested a ton of data. Now it reads 2 bytes, determines the length, then requests that much.</p>
Genetic Algorithm in Python source code - AI-Junkie tutorial (Python)
2012-06-19T12:59:13-07:00David Adlerhttp://code.activestate.com/recipes/users/4182015/http://code.activestate.com/recipes/578128-genetic-algorithm-in-python-source-code-ai-junkie-/
<p style="color: grey">
Python
recipe 578128
by <a href="/recipes/users/4182015/">David Adler</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/artificial/">artificial</a>, <a href="/recipes/tags/genetic/">genetic</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/neural/">neural</a>, <a href="/recipes/tags/python/">python</a>).
Revision 5.
</p>
<p>A simple genetic algorithm program. I followed this tutorial to make the program <a href="http://www.ai-junkie.com/ga/intro/gat1.html." rel="nofollow">http://www.ai-junkie.com/ga/intro/gat1.html.</a></p>
<p>The objective of the code is to evolve a mathematical expression which calculates a user-defined target integer.</p>
<hr />
<p>KEY:</p>
<p>chromosome = binary list (this is translated/decoded into a protein in the format number --> operator --> number etc, any genes (chromosome is read in blocks of four) which do not conform to this are ignored.</p>
<p>protein = mathematical expression (this is evaluated from left to right in number + operator blocks of two)</p>
<p>output = output of protein (mathematical expression)</p>
<p>error = inverse of difference between output and target</p>
<p>fitness score = a fraction of sum of of total errors</p>
<hr />
<p>OTHER:</p>
<p>One-point crossover is used.</p>
<p>I have incorporated <strong>elitism</strong> in my code, which somewhat deviates from the tutorial but made my code more efficient (top ~7% of population are carried through to next generation)</p>
Batch Local Network Messaging System (Batch)
2012-02-03T01:41:41-08:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578028-batch-local-network-messaging-system/
<p style="color: grey">
Batch
recipe 578028
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/alex/">alex</a>, <a href="/recipes/tags/batch/">batch</a>, <a href="/recipes/tags/batch_file/">batch_file</a>, <a href="/recipes/tags/dos/">dos</a>, <a href="/recipes/tags/messaging/">messaging</a>, <a href="/recipes/tags/messenger/">messenger</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/wallar/">wallar</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/wired/">wired</a>, <a href="/recipes/tags/wired_network/">wired_network</a>).
Revision 3.
</p>
<p>This is a Batch Local Messaging System that can be used to send messages between computers that share the same file system.</p>
<p>There are three files in the code below. They are separated with dashed lines. There is a comment on the top of each segment of code indicating the file name that the code needs to be saved as. They need to be saved as three separate batch files in the same folder. </p>
<p>The first file, MessengerMain.bat will ask you for your name and then an address. The name should be whatever you wish your screen name to be. The address needs to be the path of the FOLDER that is shared between you and the other computer that you are communicating with. Once these pieces of information are entered, two screens will appear. The first is the Sender screen and the other is the Receiver screen. </p>
<p>How does it work?
The MessengerMain.bat file will create two text files, Name.txt and Address.txt, that will hold your user name and the common folder address. It will then use the START command to run Sender.bat and Receiver.bat. Sender.bat will create a text file named msgtext.txt in the address folder you specified in MessengerMain.bat. If there is already a file of this sort in existence in the address folder, it will overwrite it. Once this file is created, any message you enter will be saved in the msgtext.txt file after the name you entered (%name%: %msg%). Sender.bat the CLS (clears) the screen and asks you for another message continuously. Receiver.bat is very similar. Receiver.bat, first off, reads the Address.txt file and the Name.txt file to find your information given in MessengerMain.bat just like Sender.bat does. It will count the number of lines in the msgtext.txt file and will clear the whole screen and print out the whole contents of the file if the number of lines in msgtext.txt increases. So basically you are writing to a shared file and reading from a shared file. </p>
<p>Example:</p>
<p>I have a folder called MSGFolder located in the folder as I have my MessengerMain.bat, Receiver.bat, and Sender.bat files. I then run MessengerMain.bat by double clicking on the icon. I enter Alex for my Name and MSGFolder as the Address. I then double click MessengerMain.bat again and enter the name Bob for Name and MSGFolder for Address. Once you do this you can type in either of the Sender.bat interfaces and it will show up as if you are talking. </p>
Show all the telecommuting jobs from the Python Job Board (Python)
2011-12-09T07:38:28-08:00Victor Yanghttp://code.activestate.com/recipes/users/627255/http://code.activestate.com/recipes/577979-show-all-the-telecommuting-jobs-from-the-python-jo/
<p style="color: grey">
Python
recipe 577979
by <a href="/recipes/users/627255/">Victor Yang</a>
(<a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/screenscrape/">screenscrape</a>).
</p>
<p>It is running as a cronjob on a VPS(Virutal Private Server). The output html can be served by any web server. </p>
Send an HTML email with embedded image and plain text alternate (Python)
2011-06-12T18:38:47-07:00soham vaghelahttp://code.activestate.com/recipes/users/4178285/http://code.activestate.com/recipes/577752-send-an-html-email-with-embedded-image-and-plain-t/
<p style="color: grey">
Python
recipe 577752
by <a href="/recipes/users/4178285/">soham vaghela</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>HTML is the method of choice for those wishing to send emails with rich text, layout and graphics. Often it is desirable to embed the graphics within the message so recipients can display the message directly, without further downloads.</p>
<p>Some mail agents don't support HTML or their users prefer to receive plain text messages. Senders of HTML messages should include a plain text message as an alternate for these users.</p>
<p>This recipe sends a short HTML message with a single embedded image and an alternate plain text message.</p>
Send an HTML email with embedded image and plain text alternate (Python)
2011-06-12T18:38:14-07:00soham vaghelahttp://code.activestate.com/recipes/users/4178285/http://code.activestate.com/recipes/577751-send-an-html-email-with-embedded-image-and-plain-t/
<p style="color: grey">
Python
recipe 577751
by <a href="/recipes/users/4178285/">soham vaghela</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>HTML is the method of choice for those wishing to send emails with rich text, layout and graphics. Often it is desirable to embed the graphics within the message so recipients can display the message directly, without further downloads.</p>
<p>Some mail agents don't support HTML or their users prefer to receive plain text messages. Senders of HTML messages should include a plain text message as an alternate for these users.</p>
<p>This recipe sends a short HTML message with a single embedded image and an alternate plain text message.</p>
ASIO Proxy (Python)
2011-04-17T15:08:30-07:00Aaron Riekenberghttp://code.activestate.com/recipes/users/4177692/http://code.activestate.com/recipes/577663-asio-proxy/
<p style="color: grey">
Python
recipe 577663
by <a href="/recipes/users/4177692/">Aaron Riekenberg</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>TCP proxy implemented using asio.</p>
ASIO (Python)
2011-04-17T15:03:23-07:00Aaron Riekenberghttp://code.activestate.com/recipes/users/4177692/http://code.activestate.com/recipes/577662-asio/
<p style="color: grey">
Python
recipe 577662
by <a href="/recipes/users/4177692/">Aaron Riekenberg</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>Asynchronous TCP socket service</p>
dhcp query (Python)
2011-04-10T15:41:14-07:00hassanehttp://code.activestate.com/recipes/users/4177610/http://code.activestate.com/recipes/577649-dhcp-query/
<p style="color: grey">
Python
recipe 577649
by <a href="/recipes/users/4177610/">hassane</a>
(<a href="/recipes/tags/dhcp/">dhcp</a>, <a href="/recipes/tags/ipv4/">ipv4</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/query/">query</a>, <a href="/recipes/tags/querying_dhcp_for_free_ip_address/">querying_dhcp_for_free_ip_address</a>).
</p>
<p>a simple python script that sends a dhcp discover packet and recieves the dhcp offer that contains a suggested ip address, gateway, dns servers and displays them.</p>
FSM 2.5 Reader (Python)
2011-04-06T03:02:57-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577639-fsm-25-reader/
<p style="color: grey">
Python
recipe 577639
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/file_io/">file_io</a>, <a href="/recipes/tags/file_share/">file_share</a>, <a href="/recipes/tags/messenger/">messenger</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/workaround/">workaround</a>).
</p>
<p>For those who would want to search the message logs produced by <a href="http://code.activestate.com/recipes/577638/">recipe 577638</a>, this program provides a command-line solution to searching messages according to their authors. If this program is placed in the message directory, the program may be executed on the command-line with the author's name as an argument. If and when the program is executed without an argument, usage information is shown on the screen before exiting. If an author was not found, the author's name is printed stating that nothing could be found. If a matching file was found, all timestamps and messages will be displayed that could be decoded correctly.</p>
<p>If there are any recommendation for this recipe or if anyone wishes to down-vote this recipe, please provide corrective criticism showing the the program's faults and give suggestions on how you would fix any problems that it might have.</p>
File Share Messenger 2.5 (Python)
2011-04-06T02:45:15-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577638-file-share-messenger-25/
<p style="color: grey">
Python
recipe 577638
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/file_io/">file_io</a>, <a href="/recipes/tags/file_share/">file_share</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/messenger/">messenger</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/workaround/">workaround</a>).
</p>
<p>After writing the limited program shown in <a href="http://code.activestate.com/recipes/577637/">recipe 577637</a>, the following program was written with a better yet incompatible I/O system designed not to fill up a file share with many, separate files. This program had five revisions as outlined within the source code. To access settings within this program, use the "F2" key. Documentation may be accessed via the "F1" key (with future plans cut).</p>
<p>If anyone wishes to comment or vote this recipe down, please provide your insight into the fault(s) of the program and provide a suggestion as to what solution you would implement to fix the problems.</p>
File Share Messenger 1.0 (Python)
2011-04-06T00:03:20-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577637-file-share-messenger-10/
<p style="color: grey">
Python
recipe 577637
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/file_io/">file_io</a>, <a href="/recipes/tags/file_share/">file_share</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/messenger/">messenger</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/workaround/">workaround</a>).
</p>
<p>File I/O has many potential uses, and in the case of network file shares, messaging can be conducted by creating files in a directory and scanning for new files to find new messages. In the case where there are restrictions within a network that prevent opening server sockets or creating and using client sockets, the technique in this recipe may be used with file shares instead. The program is simple and was written in about fifty minutes, so there are a great deal of enhancements that could be made to the recipe and its capabilities. Hopefully, this will provide inspiration for other program writers.</p>
<p>If you have any comments or wish to down-vote this recipe, please provide your insight as to what could be improved upon and how you would go about fixing any problems that you might find.</p>
NBD server in python (Python)
2011-02-08T20:59:23-08:00Dima Tisnekhttp://code.activestate.com/recipes/users/4068698/http://code.activestate.com/recipes/577569-nbd-server-in-python/
<p style="color: grey">
Python
recipe 577569
by <a href="/recipes/users/4068698/">Dima Tisnek</a>
(<a href="/recipes/tags/analyze/">analyze</a>, <a href="/recipes/tags/block/">block</a>, <a href="/recipes/tags/device/">device</a>, <a href="/recipes/tags/disk/">disk</a>, <a href="/recipes/tags/io/">io</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/nbd/">nbd</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Linux Network Block Device server in Python</p>
<p>This is a simplified version based on Kragen Sitaker's <a href="http://lists.canonical.org/pipermail/kragen-hacks/2004-May/000397.html" rel="nofollow">http://lists.canonical.org/pipermail/kragen-hacks/2004-May/000397.html</a></p>
<p>Close is never actually called, at least not on the same connection -- linux C nbd-client -d seems to stall, perhaps it tries to open another socket?</p>
<p>This code doesn't check for error conditions, failed reads/writes, past end of disk, etc.</p>
<p>It prints io requests, you can analyze filesystem and user program io patterns.</p>
Monkey-patch execnet with more ssh settings, port, identity file, non-interactive (Python)
2011-01-15T16:35:00-08:00Dima Tisnekhttp://code.activestate.com/recipes/users/4068698/http://code.activestate.com/recipes/577545-monkey-patch-execnet-with-more-ssh-settings-port-i/
<p style="color: grey">
Python
recipe 577545
by <a href="/recipes/users/4068698/">Dima Tisnek</a>
(<a href="/recipes/tags/batchmode/">batchmode</a>, <a href="/recipes/tags/execnet/">execnet</a>, <a href="/recipes/tags/identity/">identity</a>, <a href="/recipes/tags/key/">key</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/noninteractive/">noninteractive</a>, <a href="/recipes/tags/port/">port</a>, <a href="/recipes/tags/public/">public</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/ssh/">ssh</a>).
</p>
<p>execnet ( <a href="http://codespeak.net/execnet/" rel="nofollow">http://codespeak.net/execnet/</a> ) is pretty cool, but its ssh support needs a few tweaks, here they are.</p>
<p>This snipped is a monkey patch, not a diff, import it and you can use execnet.makeportgateway instead of makegateway.</p>
<p>Adapt to your needs even more!</p>
Simplest example of serving a browser request (Python)
2010-10-15T21:17:30-07:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/577428-simplest-example-of-serving-a-browser-request/
<p style="color: grey">
Python
recipe 577428
by <a href="/recipes/users/4166965/">Kaushik Ghose</a>
(<a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/webserver/">webserver</a>).
</p>
<p>This is the simplest way I have found of sending information from a python program to a browser</p>