Sample Header Ad - 728x90

'netcat' not working as expected on Arch, but works on openSUSE Tumbleweed? What's going on?

4 votes
1 answer
1136 views
I'm having a bit of trouble utilising netcat on Arch, specifically, the GNU version of it. My situation: I basically made a simple server in Python that can accept multiple clients and send responses. To test for input/output, I made a whole lot of automated testing scripts that would send data through netcat to the server and compare the output with what was expected. On the environment where I developed the server and the test cases, which was openSUSE Tumbleweed, piping text to GNU netcat with
echo "text" | netcat -w 2 -i 2 ip port > somefile.out
worked just as expected - netcat sent data to the server, got the response and redirected it to the file. However, on Arch, it almost seems like the -w or -i flags don't do anything - netcat just stays connected indefinitely until I manually have to close the connection. Even when I tried the flags individually, it exhibited similar behaviour. I tried to use another method with timeout 2 netcat ..., which does stop netcat from running, but for some reason also stops my entire script and prevents further calls to netcat from running at all. In desperation, I even tried compiling GNU netcat from source, and still faced the problem. I tried to search for anyone else having a similar issue on the internet but I wasn't able to find anything that matched my circumstances. Would anybody know what is happening? I feel like I'm losing my mind. Surely it shouldn't work differently across different distros, unless I'm misunderstanding something?
Asked by cpolish (41 rep)
Nov 16, 2021, 01:17 PM
Last activity: Aug 10, 2024, 03:38 PM