LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-01-2013, 07:36 AM   #1
waddles
Member
 
Registered: Sep 2012
Posts: 372

Rep: Reputation: 1
nc dies after reading port


I used: echo Hello > /dev/udp/127.0.0.1/12345
to test nc using: nc -ul -p 12345 in a different window (xfce)
nc will accept only 1 input and hangs; it does not terminate.
This is on Slackware 13.37 and the man page does not indicate that this is any standard procedure in fact to the contrary. I closed the echo command after sending the salutation but to no avail.
Any ideas why nc goes to sleep after the initial reading?
 
Old 01-04-2013, 01:26 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Moved: This thread is more suitable in Linux Software and has been moved accordingly to help your question get the exposure it deserves.
 
Old 01-04-2013, 01:31 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Using -p with -l is "in error" according to the man page for nc. Use "nc -ul 12345" to listen on port 12345
 
Old 01-04-2013, 02:56 PM   #4
waddles
Member
 
Registered: Sep 2012
Posts: 372

Original Poster
Rep: Reputation: 1
nc dies after reading port

Yeh - I've seen that referenced on the internet. Here is what my man page says:
nc -l -p port [-options] [hostname] [port]
This may be due to change in version, I'm not sure tho.
 
Old 01-04-2013, 03:48 PM   #5
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,508

Rep: Reputation: 800Reputation: 800Reputation: 800Reputation: 800Reputation: 800Reputation: 800Reputation: 800
I have come across this also, and read the same pages by the sounds of it. I'm afraid I don't recall what I ended up using but I managed to have nc terminate after a successful message and that was it, but I am sure the man pages say it will go on listening indefinitely?
 
Old 01-05-2013, 02:31 AM   #6
waddles
Member
 
Registered: Sep 2012
Posts: 372

Original Poster
Rep: Reputation: 1
I used 127.0.0.1 localhost to test and after the first datagram that nc received it would not receive successive datagrams.
 
Old 01-06-2013, 05:22 AM   #7
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
There is a netcat from netcat-openbsd package and another from a netcat-traditional package. That explains the -p differences, but not your question.

I think it has to do with the terminal or readline buffering rather than netcat. I may need to press ctrl-c after exiting from an ssh session.

I can verify that I see the same behaviour as you.

P.S. The listening terminal returns on killing nc. A sending nc doesn't return after
nc -u host 12345 < file

Last edited by jschiwal; 01-06-2013 at 05:55 AM.
 
  


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
data push from box to removable usb drive dies, then dies, then dies again. bodyofabanshee Linux - Server 11 03-15-2012 12:34 PM
Login window dies when user authentication dies. Hom Linux - Newbie 2 03-09-2011 06:52 AM
Ethernet port dies after a few seconds of use (Intel 82583V) Potatos Linux - Hardware 2 07-19-2010 06:09 PM
Serial port reading jayadhanesh Linux - Newbie 3 05-19-2009 07:54 PM
mysqld running and reading for connections on port 3306, no port 3306 found from scan darkenigmaa Linux - Networking 7 09-21-2005 11:10 AM


All times are GMT -5. The time now is 07:06 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration