java - How to connect to Unix Domain Socket on client side service knowing only socket file descriptor
问题描述
My Service A communicates with another Service B on the same host through UNIX Domain Socket (UDS). The only information I have is a value of socket file descriptor with which the Service B is ready to send data through socket to Service A. I use 3rd party library junixsocket to communicate through UDS between services. And my question is how using this library I can connect to the socket on Service A side knowing only the socket file descriptor?
I just found how to connect to socket on Service A side with socketPath:
File socketFile = new File("/path/to/your/socket"); AFUNIXSocket sock = AFUNIXSocket.newInstance(); sock.connect(new AFUNIXSocketAddress(socketFile));
But I need to know how to connect to it with just file descriptor
I’m using openJDK-11, that’s why I have to use 3rd party library for UDS communication
解决方案
推荐阅读
- r - 使用 PlumberDeploy 包在 Digital Ocean 上部署 R 管道工 API
- mobile - 选择焦点在输入元素上的文本
- javascript - 如何比较日期并对来自 javascript 中的 api 的数据进行排序?
- python - 如何在 QuickBooks Online 中获取会计“截止日期”
- json - 为什么通过邮递员发布 json 时出现范围不足的错误?
- c++ - 为什么 dlsym 在动态加载的库中找不到函数?
- powershell - 检查远程端口是否打开并使用时间戳记录
- javascript - 从 UserAgent 对象(koa-useragent)获取属性
- javascript - PM2重启延迟Node.js
- if-statement - 如何查看页面上的段落并搜索关键字?(并且还建立一个重定向到正确结果的关键字列表/目录)