Giter VIP home page Giter VIP logo

netty-named-pipe's Introduction

netty-named-pipe

This netty example shows how to use named pipes under Linux and/or Mac OS. It is based on the FileServer example.

How to run the example

You will need three terminal windows to run this example. In the first window, you start the TCP server:

alec@mba ~/project/minetats-all/netty-named-pipe (master) $ ./gradlew run

The TCP server listens on port 8023. When it starts, you connect to it in the second terminal window:

alec@mba ~/process $ telnet 127.0.0.1 8023
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HELO: Type the path of the file to retrieve.

Now it is time to start the named pipe in the third terminal window:

alec@mba ~/project/minetats-all/netty-named-pipe/named_pipe (master) $ ./named_pipe_test.sh && \
          tail -f named_pipe.log 
named_pipe.sh started on Sun Feb 19 14:28:41 EST 2017, PIPE=/tmp/S043004-v2-1.txt
PID_UNZIP = 23260

Now you copy and paste /tmp/S043004-v2-1.txt (the name of the named pipe) into the second window and press Enter (in the second window) to start the example. On my mac, it runs for about 30 seconds. When it stops, you see the Connection closed by foreign host. message in the second window. It is now time to enter Ctrl-C in the first and in the third window to stop the TCP server and the unzip process. To complete the cleanup, run rm /tmp/S043004-v2-1.txt.

The use case

The use case behind this example is serving the market feed data (a tiny portion of some historical ITCH in our case) to multiple clients in parallel. The data is being kept in a zip file. When a client requests the feed, a new process starts unzipping the data into a new named pipe. The TCP server reads the data from this named pipe and passes it on to the client.

I have a project called Market Feed on Demand that is based on the approach presented in this example.

Presently using http, not https, in my gradle files

On my mac, I tried to take care of the certificates used by my mac's JRE. Although I did that in the past more than once, I need guidance each time I use keytool. This time, I found an excellent resource: Joshua Davies covered this in his blog. So I just had to follow his lead (or so I thought).

alec@mba ~/project/minetats-all/netty-named-pipe/named_pipe (master) $ sudo find / -type f -name cacerts
...
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/security/cacerts

alec@mba ~/project/minetats-all/netty-named-pipe/named_pipe (master) $ keytool -list -keystore /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/security/cacerts

alec@mba ~/project/minetats-all/netty-named-pipe/named_pipe (master) $ keytool -printcert -rfc -sslserver jcenter.bintray.com > certs
alec@mba ~/project/minetats-all/netty-named-pipe/named_pipe (master) $ sudo keytool -importcert -file ./certs -keystore /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/security/cacerts -alias jcenter
Password:
Enter keystore password:  
...
Trust this certificate? [no]:  yes
Certificate was added to keystore

Should have worked, but didn't. So I just switched from https to http in my gradle files. I wish I knew what was (and still is) wrong with cacerts on my mac...

netty-named-pipe's People

Contributors

amissine avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.