LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-08-2021, 05:39 PM   #16
rootaccess
Member
 
Registered: Mar 2012
Posts: 227

Original Poster
Rep: Reputation: Disabled

edited first post

Last edited by rootaccess; 11-09-2021 at 12:46 AM.
 
Old 11-10-2021, 11:19 AM   #17
rootaccess
Member
 
Registered: Mar 2012
Posts: 227

Original Poster
Rep: Reputation: Disabled
I was able to figure this out by rebuilding ncat. it was complicated since many other functions were handling connections, streams etc. read_socket() actually gets called for each chunk even though there is a loop inside it as well. i passed a file pointer into it and then closed it if n was less than 0. but now i am dealing with potential race conditions if one client opens a connection with nc, whether there is input or not from stdin (file or data), if another user sends a file, it works, but then if the original user closes the connection, my program crashes. seems like i need a way of handling stdin better...to timeout or close the connection if there isn't a stream of data coming in immediately.
 
Old 11-10-2021, 11:37 AM   #18
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,224
Blog Entries: 1

Rep: Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585
You might want to use `inetd`: it handles networking, and starts a new process (fork(2)) for every client connection, your program just reads stdin and writes stdout.
https://en.wikipedia.org/wiki/Inetd

Last edited by NevemTeve; 11-10-2021 at 12:07 PM.
 
Old 11-11-2021, 01:22 AM   #19
rootaccess
Member
 
Registered: Mar 2012
Posts: 227

Original Poster
Rep: Reputation: Disabled
You know, i looked into that, and then i realized i'll just use a PASV FTP server and write the client with the user and password in it. While it was fun modifying ncat and getting it to work somewhat, it isn't really practical since I still wouldn't be able to get the original file name from the source machine, since it would change based on time, etc. And I don't want to deal with figuring out all this race condition stuff either. If I had endless time, I guess I ....still wouldn't want to. LOL.
 
  


Reply

Tags
c++, linux, networking, programming


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
LXer: Large botnet of CCTV devices knock the snot out of jewelry website LXer Syndicated Linux News 0 06-27-2016 10:24 PM
LXer: Microsoft: Knock, Knock, Knocking on Nokia’s Door LXer Syndicated Linux News 0 09-14-2013 01:52 AM
Knock knock kandiru LinuxQuestions.org Member Intro 1 03-31-2009 04:40 PM
LXer: Knock, Knock, Knockin' on EnGarde's Door (with FWKNP) LXer Syndicated Linux News 0 12-05-2007 01:50 AM
LXer: Knock Knock. Who's There? Mandriva LXer Syndicated Linux News 0 12-16-2005 03:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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