You are not logged in.

#1 2025-03-20 16:27:43

gutsthakur
Member
Registered: 2024-12-30
Posts: 4

netcat not working with the flags [SOLVED]

I am writing a program that listens on a specific port for the data, then I run the command

nc -w 1 127.0.0.1 42089

with the flag

-w

set to 1, so that it will close the connection after 1 sec of Idle or no connection.

But using this flag is not working, the

nc

indefinitely listens on the connected port or my server listens on the connected port as the connection from the

nc

is not broken.

Last edited by gutsthakur (2025-03-23 07:00:55)

Offline

#2 2025-03-20 17:43:03

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,307

Re: netcat not working with the flags [SOLVED]

There exist two netcat implementations, which one do you have installed and are you potentially mixing up flags for one or the other? (hint the packages are openbsd-netcat and gnu-netcat), though for this particular case both "should" be more or less identical

Offline

#3 2025-03-21 02:05:11

gutsthakur
Member
Registered: 2024-12-30
Posts: 4

Re: netcat not working with the flags [SOLVED]

I have `gnu-netcat` installed on my system.

Offline

#4 2025-03-21 02:12:19

gutsthakur
Member
Registered: 2024-12-30
Posts: 4

Re: netcat not working with the flags [SOLVED]

Well I installed the openbsd-netcat implmentation and it worked just fine.

Offline

#5 2025-03-21 06:27:01

seth
Member
Registered: 2012-09-03
Posts: 62,944

Re: netcat not working with the flags [SOLVED]

\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB