Make One Echo Server Work with Both TCP and Unix Sockets | Challenge

00:00:40 ・ source: https://labs.iximiuz.com/challenges/write-stream-echo-server

Transcript

hostenToday we build an echo server that works with both TCP and Unix sockets.
guestjaTCPとUnixソケットの両方に対応したエコーサーバーを作るということですね。
hostenExactly—the same program listens on either TCP like 127.0.0.1:4000 or Unix paths like unix:///tmp/echo.sock.
guestjaコマンドライン引数で起動時にどちらを選ぶかを指定するんですね。
hostenRight—parse the argument, create the right socket type, then the accept-echo loop is identical for both.
guestja重要なのは、ソケット作成時にアドレスファミリーを変えるだけで、あとの処理は共通ということですね。