简体   繁体   English

使用带有Boost ASIO的UDP的文件套接字I / O.

[英]File socket I/O using UDP with Boost ASIO

So I'm trying to use boost.log with the syslog sink on my FreeBSD servers, which run rsyslogd and listen on a file socket for UDP data. 所以我试图在我的FreeBSD服务器上使用带有syslog接收器的boost.log,它运行rsyslogd并在文件套接字上侦听UDP数据。 Apparently this works in FreeBSD land. 显然这适用于FreeBSD的土地。 Indeed the file socket is a dgram socket (telnet to a file socket is another thing which works in FreeBSD): 实际上文件套接字是一个dgram套接字(telnet到文件套接字是另一个在FreeBSD中工作的东西):

$ telnet /var/run/log
Trying /var/run/log...
/var/run/log: Protocol wrong type for socket

At any rate, boost.log will not communicate with a file socket, only with an IP address. 无论如何,boost.log不会与文件套接字通信,只能与IP地址通信。 My plan is to proxy information between a regular IP-based UDP server which my application relays to the file socket. 我的计划是在我的应用程序中继到文件套接字的常规基于IP的UDP服务器之间代理信息。 In theory, this should work fine. 理论上,这应该工作正常。

However, I cannot find any way to get ASIO to communicate over UDP with a file socket, or even a file socket at all. 但是,我找不到任何方法让ASIO通过UDP与文件套接字,甚至文件套接字进行通信。 I understand there may be ways of working with file I/O using ASIO, but this seems to be a hard Google search - nothing relevant comes up. 我知道可能有使用ASIO处理文件I / O的方法,但这似乎是一个艰难的谷歌搜索 - 没有任何相关性。 Only a few things (on this very site) which have to deal with Windows file I/O and ASIO, at best. 只有少数(在这个网站上)必须处理Windows文件I / O和ASIO,最多。

Ideally, I'd be looking for something like this (though this doesn't exist at all): 理想情况下,我会寻找这样的东西(虽然这根本不存在):

socket.send_to(boost::asio::buffer(data, length),
               boost::asio::ip::udp::endpoint(boost::asio::ip::file_address("/var/run/log"), port);

But I'll take anything that'll work. 但我会采取任何有用的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM