Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your invocation of <a href="http://linux.die.net/man/1/nc" rel="nofollow"><code>nc</code></a> is bad, what will happen if I invoke this as you in command line:</p> <pre><code># Server window: [vyktor@grepfruit ~]$ nc -l 5050 # Client Window [vyktor@grepfruit ~]$ nc localhost 5050 [vyktor@grepfruit ~]$ echo $? 1 </code></pre> <p>Which mean (<code>1</code> in <code>$?</code>) failure.</p> <p>Once you use <code>-p</code>:</p> <pre class="lang-none prettyprint-override"><code>-p, --local-port=NUM local port number </code></pre> <p>NC starts listening, so:</p> <pre><code># Server window [vyktor@grepfruit ~]$ nc -l -p 5050 # Keeps handing # Client window [vyktor@grepfruit ~]$ echo Hi | nc localhost 5050 # Keeps hanging </code></pre> <p>Once you add <code>-c</code> to client invocation:</p> <pre class="lang-none prettyprint-override"><code>-c, --close close connection on EOF from stdin </code></pre> <p>You'll end up with this:</p> <pre><code># Client window [vyktor@grepfruit ~]$ echo Hi | nc localhost 5050 -c [vyktor@grepfruit ~]$ # Server window [vyktor@grepfruit ~]$ nc -l -p 5050 Hi [vyktor@grepfruit ~]$ </code></pre> <p>So you need this python piece of code:</p> <pre class="lang-python prettyprint-override"><code>#!/usr/bin/env python import subprocess lookup_server = subprocess.Popen("nc -l -p 5050", shell=True) lookup_client = subprocess.Popen("nc -c localhost 5050", shell=True, stdin=subprocess.PIPE) lookup_client.stdin.write("magic\n") lookup_client.stdin.close() # This lookup_client.send_signal(subprocess.signal.SIGINT) # or this kill lookup_server.wait() print "Lookup server terminated properly" </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload