LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2018, 04:10 PM   #1
crabbit
LQ Newbie
 
Registered: Feb 2018
Posts: 13

Rep: Reputation: Disabled
Using netcat to pipe stdout to pipe


I am writing an application that reads serial data that is transmitted over tcp using a pi.

What I would like to do is while logged in as pi (rrot in production):

mkfifo /tmp/pipe
chmod 666 /tmp/pipe
run my c program that opens and reads /tmp/pipe using open() and read()
then run nc -lk 5000 > /tmp/pipe.

when I try to test I connect to the pi using putty (set up raw, no editing, ip addy port 5000)

Putty returns connection refused.

Where am I going wrong here?
 
Old 03-07-2018, 05:31 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
If I understand the question a ready made solution that converts serial data to TCP is ser2net. I've used socat to create a virtual serial port for minicom and cutecom but have not tried a raw connection with PuTTy

http://techtinkering.com/2013/04/02/...rt-over-tcpip/
 
Old 03-09-2018, 12:30 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,939

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
Trying to use putty to receive netcat?? Did I get this wrong?
 
Old 03-10-2018, 08:07 AM   #4
crabbit
LQ Newbie
 
Registered: Feb 2018
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
Trying to use putty to receive netcat?? Did I get this wrong?
Putty from a different system. It works if I do not redirect to a pipe.

I have it working with socat (link to ttyS1 that another program reads from).

socat pty,link=/dev/ttyS1,raw,echo=0 tcp-listen:5000,forever,max-children=1,fork

Last edited by crabbit; 03-10-2018 at 08:10 AM.
 
Old 03-10-2018, 08:13 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
would be nice to see that c program, probably buffer related....
 
Old 03-27-2018, 12:06 PM   #6
erabaddosi-2116
LQ Newbie
 
Registered: Mar 2018
Posts: 20

Rep: Reputation: Disabled
Hi crabbit,

Shell-based pipes buffer different amounts of data until told to flush. While piping from the shell may work in a pinch, you'll start to get odd delays. Symptomatic of this that the c program is always waiting for data. Since you are working in C, it may be more efficient to open your own network sockets and dealing with those putty connections a little more directly. Depending upon what you are doing, you might also be able to open local or remote tunnels in an ssh connection to move TCP traffic around w/o needing to manually handle network sockets.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pipe on other than stdout usao Linux - General 1 10-08-2015 06:22 PM
Pipe 'echo' to 'netcat' - sometime it seems to broken quanta Linux - Server 2 09-05-2010 09:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration