'How can I send a UDP packet from bash and receive the response
I want to send a UDP packet from bash (perhaps using netcat or socat) and then receive the one-packet reply, or time-out after three seconds.
(Strictly, the listening needs to start before the initial packet is sent.)
Is this possible, or do I need to write my own small C program?
- Netcat lets me either send or receive, so it won't do the job.
- Likewise for socat.
- Perhaps there is already a UDP request/response tool, but I don't know how to find it.
I need to write my own program for this use case.
Solution 1:[1]
Socats datagram mode works asynchronously. In particular, something like
socat -t 3 - UDP-DATAGRAM:localhost:7777,bind=:6666
might come near your requirements.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
