LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 06-07-2017, 04:39 AM   #1
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,333
Blog Entries: 3

Rep: Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729
Shell utility for making a UNIX domain socket?


Is there a utility available that can make a UNIX domain socket right from the shell? Or do I have to use perl, python, or something else to make one?

For example:

Code:
srw-rw----  1 root  wheel       0B Jun  4 15:10 test.sock
The utility mknod can make a few special files, including named pipes, but not sockets. The utility touch can only make regular files. Maybe there is something just for sockets?
 
Old 06-07-2017, 05:21 AM   #2
serafean
Member
 
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 997
Blog Entries: 15

Rep: Reputation: 136Reputation: 136
netcat is what you want (often under the nc command).

from man nc:
Quote:
-U' Specifies to use Unix Domain Sockets.
nc -U $PATH
 
1 members found this post helpful.
Old 06-07-2017, 05:34 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,333

Original Poster
Blog Entries: 3

Rep: Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729
Thanks. That does it, though the -l option seems to be needed.

Code:
nc -l -U /tmp/foo.sock & kill $!;
 
Old 06-07-2017, 05:58 AM   #4
serafean
Member
 
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 997
Blog Entries: 15

Rep: Reputation: 136Reputation: 136
Quote:
Originally Posted by Turbocapitalist View Post
Thanks. That does it, though the -l option seems to be needed.
Code:
nc -l -U /tmp/foo.sock & kill $!;
Right, I forgot you wanted a "listening" socket...
Also recommended with -l is
Quote:
-k Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option.
 
  


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
UNIX domain socket amir_skh Programming 6 11-15-2010 04:44 AM
any way to kill/disconnect a unix domain socket? ciuly Linux - Networking 2 01-06-2010 02:38 PM
Binding to Unix Domain Socket blank87 Programming 1 06-18-2008 06:19 PM
PHP UNIX Domain Socket Programming anamericanjoe Programming 2 12-08-2006 02:10 AM
unix domain socket: how to know if i use recvmsg or read Thinking Programming 3 09-23-2005 01:51 AM

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

All times are GMT -5. The time now is 05:45 PM.

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