2016-04-15 45 views
0

我有应用程序A和B,它们使用unix套接字进行通信。我需要的是点击这个插座并聆听/发送评估通讯?如何点击unix套接字

socat -t100 -x -v UNIX-LISTEN:/tmp/.sock,mode=777,reuseaddr,fork ,UNIX-CONNECT:/tmp/.sock_original 

适用于转储到控制台,但我怎么能像UDP-SENDTO添加? 我可以吗? 谢谢。

+0

我相信这已[先前问](http://superuser.com/questions/484671/can-i-monitor-a-local-unix-domain-socket-like-tcpdump)。 –

回答

0

好吧,我找到了方法。这不是最优的,但工作

socat -t100 -x -v UNIX-LISTEN:/tmp/.sock,mode=777,reuseaddr,fork ,UNIX-CONNECT:/tmp/.sock_original | 
awk '{ if (lines > 0) { print; --lines; }} /^>/ { lines = 1}' | while read -r line; do echo $line > /dev/udp/localhost/6543; done 

它过滤出的第一行,只发出一个方向的数据包(/ ^> /)。