netcatによって簡単な通信が行えるようだ。tmuxで確認してみる。
Debian系OSとして、まずaptでnetcatを入れる。
# apt install netcat
するとncコマンドが使用できるようになる。
# nc -h [v1.10-41.1] connect to somewhere: nc [-options] hostname port[s] [ports] ... listen for inbound: nc -l -p port [-options] [hostname] [port] options: -c shell commands as `-e'; use /bin/sh to exec [dangerous!!] -e filename program to exec after connect [dangerous!!] -b allow broadcasts -g gateway source-routing hop point[s], up to 8 -G num source-routing pointer: 4, 8, 12, ... -h this cruft -i secs delay interval for lines sent, ports scanned -k set keepalive option on socket -l listen mode, for inbound connects -n numeric-only IP addresses, no DNS -o file hex dump of traffic -p port local port number -r randomize local and remote ports -q secs quit after EOF on stdin and delay of secs -s addr local source address -T tos set Type Of Service -t answer TELNET negotiation -u UDP mode -v verbose [use twice to be more verbose] -w secs timeout for connects and final net reads -C Send CRLF as line-ending -z zero-I/O mode [used for scanning] port numbers can be individual or ranges: lo-hi [inclusive]; hyphens in port names must be backslash escaped (e.g. 'ftp\-data').
いったんlocalhostで通信をすることを考える。まずtmuxを起動する。
# tmux
tmuxで「<Ctrl-b>+%」によって、画面を左右のペインに分割する。分割したペインは「<Ctrl-b>+o」で行き来できる。
ここまで準備が整ったら、まず片方のペインでnetcatを実行する。
# nc -l -p 4693
オプション-l
はリッスンモード、-p {数}
はポート番号の指定である。実行すると入力待ちのような状態になる。この状態でもう一方のペインに移動し、次のコマンドを実行する。
# nc localhost 4693
こちらも入力待ちの状態になる。どちらか一方のペインで文字を入力してエンターを押すと、もう一方のペインにも文字が出力される。 どちらか一方のペインで<Ctrl-C>を押すと両方のペインでnetcatが停止する。