title: Test if netcat listener got a connection and run a command locally
body: <p>I need a way to fire a netcat listener from a shell script and if a connection received I need to run a command on the same local listener machine and without interrupting the netcat process / connection
  it's like the -e option but I need to run a command locally while keeping the netcat connection running</p>
  
  <p>I don't really know if it can be done I mean after the shell process forked the netcat child can it interact with nc's output for example and run other command before netcat exit?</p>
  
  <p>Edit: I figured it's even easier to do it on the client C code side by checking the return value of an initial send() message to determine if the client connected successfully if we got the sent message length   </p>
  
  <pre><code>sret = send(sock, message, strlen(message), 0);
  if (sret == strlen(message)) // We're Connected
     do something
  </code></pre>
  
  <p>Thanks</p>