-
-
Save csobankesmarki/1bc378c0c0e1eb9cb78a5cdd447a4c4f to your computer and use it in GitHub Desktop.
Read and write to a socket using only Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Bash must have been compiled with this ability: --enable-net-redirections | |
# The device files below do not actually exist. | |
# Use /dev/udp for UDP sockets | |
exec 3<>/dev/tcp/host/port | |
# Write to the socket as with any file descriptor | |
echo "Write this to the socket" >&3 | |
# Read from the socket as with any file descriptor | |
cat <&3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment