Centos6

與 centos 6.9 的 apt-get install socket 類似的軟體包

  • July 5, 2018

我需要在 CentOS 上執行一個套接字,就像我們socket在 Ubuntu 上安裝的一樣。有沒有類似的方法可以在 CentOS 上做到這一點?

**注意:**我可以簡單地socket在 Ubuntu 上執行socket -sl 555 -B 0.0.0.0

背景

根據你的問題,我假設你的意思是你socket的 Ubuntu 機器上有這個包:

$ sudo apt-cache show socket
Package: socket
Priority: optional
Section: universe/net
Installed-Size: 76
Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>
Original-Maintainer: LENART Janos <ocsi@debian.org>
Architecture: amd64
Version: 1.1-10
Depends: libc6 (>= 2.4)
Filename: pool/universe/s/socket/socket_1.1-10_amd64.deb
Size: 16846
MD5sum: b258cb002cd0bf83ef7cd81ea8ebc203
SHA1: 45964483ba4c7b29ac90ec6ddd57b87bb2c8f507
SHA256: 9b3496c61a5d81241ab83c7541de456a4e0f8d2ade3eaa122e6f64ab28e81c2b
Description-en: Multi purpose socket tool
The socket program is a simple tool for socket based connections. It
can be used to create simple daemons (in both standalone and inetd
mode), to connect to other daemons or to redirect ports.
Description-md5: 286dc3011950982c9923a6a69c875ca9
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu

我在任何 CentOS YUM 儲存庫中都沒有看到這個軟體包,從它的外觀來看,它已經過時了。自 2009 年以來似乎沒有更新:

2009-04-14 - LENART Janos 插座 (1.1-10) 不穩定;urgency=low * (Re-) 採用包。(關閉:#487341)* 應用了來自 Andras Pal 的出色更新檔 + 修復了一些缺失的標頭 +(希望)完全支持 UNIX 域套接字

備擇方案

鑑於這一切,我傾向於使用nc(netcat) 或socat. 有幾個食譜展示瞭如何使用socat.

類似於您使用此命令顯示的內容:

$ socket -sl 555 -B 0.0.0.0

可以用 來實現nc,例如:

$ nc -4 -l -p 555 -k

或與socat

$ socat - tcp-l:555,ignoreeof

引用自:https://serverfault.com/questions/919413