LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2015, 06:57 PM   #1
skwilson78
LQ Newbie
 
Registered: Jul 2015
Posts: 2

Rep: Reputation: Disabled
What are socket and pipe files?


I am studying for the LPIC and I came across ls -F or file type and when it shows the indicator it mentions = as meaning socket and | as pipe. I know what a pipe is but does that mean there is such a thing as a pipe file?? Also what is a socket file or what does this mean if I am reading into it wrong? Probably a dumb question but it would be great if someone could fill me in. Thanks
 
Old 07-14-2015, 09:48 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Both are inter-process communication facilities. Sockets, also known as UNIX sockets, have the same programming interface and behaviour as network sockets, whereas named pipes, also known as FIFOs, behave like unnamed pipes.

The socket interface is described in the unix manual page (man 7 unix). Named pipes in man 7 fifo.
 
Old 07-15-2015, 09:54 AM   #3
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
Basic unix philosophy is everything is a file
So yes, there is a pipe file.

This link helps explain
http://www.informit.com/articles/art...9706&seqNum=15

Quote:
Some systems provide the pathnames /dev/stdin, /dev/stdout, and /dev/stderr. These are equivalent to /dev/fd/0, /dev/fd/1, and /dev/fd/2.
Unless I'm mistaken, this can be very similar

command1 | command2 | command3

command1 output to stdout, command2 takes command1's stdout as its stdin, processes it and sends the output to stdout, command3 takes command2's stdout as its stdin, processes it and sends it out to stdout, which is then interpreted by /dev/tty (the current terminal process) and displays it on screen.
 
Old 07-15-2015, 10:05 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
The primary difference is that a socket is designed to provide a bidirectional data transfer without deadlocking... You can still deadlock, but the fault is then within the application.

A fifo/pipe will fill to its buffer, then block until something reads from it. It is a one way transfer.

You can also use a socket as if it were a pipe - but you cannot treat a pipe as a socket.

Last edited by jpollard; 07-15-2015 at 10:06 AM.
 
Old 07-15-2015, 12:09 PM   #5
skwilson78
LQ Newbie
 
Registered: Jul 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thaks

Thank you this helped. Here is a link that I found when researching your replys. It explains sockets and how unix uses file descripters for everything. I am posting it to help someone in the future. http://beej.us/guide/bgnet/output/ht...ge/theory.html
 
Old 07-15-2015, 03:48 PM   #6
igadoter
Senior Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: many, primary Slackware
Posts: 2,717
Blog Entries: 1

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
Code:
[piotr@druid ~]$ mkfifo foo 
[piotr@druid ~]$ cat > foo
ola
ola
ola
go to another terminal and do
Code:
[piotr@druid ~]$ cat foo
ola
ola
ola
some editors are able to open pipes, as common files and read from them. I was using this in kwrite in KDE 3.5.12.
 
  


Reply



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
python: socket broadcast produces a broken pipe eantoranz Programming 2 04-14-2009 08:24 AM
Stop perl socket server broken pipe or exiting son_t Programming 1 10-25-2007 03:52 AM
how does one use DD to recombine files from using pipe to split files originally? nerdful1 Linux - General 3 03-28-2006 07:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:28 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