c - Get the socket from an Apache module
问题描述
I need to retrieve the socket object in an apache C module. I have read the documentation and didn't find a way to retrieve this.
However, I can get the apr_sockaddr_t
object for a request
解决方案
Here is a way to do it :
apr_socket_t *asock = ap_get_conn_socket(req->connection);
int fd = 0;
apr_os_sock_get(&fd, asock);
char buf[1024] = "HTTP/1.1 200 OK\r\nContent-Length: 34\r\nContent-Type: text/html\r\nHost: localhost\r\n\r\nHELLO WORLD FROM AN AWESOME SOCKET";
write(fd, buf, strlen(buf));
close(fd);
推荐阅读
- r - 绘图编码 R
- css - 我似乎找不到如何将我的 mp4 文件添加为标题而不是图片
- swift - 将字符串与 UIStepper 一起使用 - Swift
- r - 本地连接的一维自动编码器
- laravel - Laravel 6:如何覆盖 sendPasswordResetNotification 函数
- c++ - 如何从另一个结构为结构赋值?
- linux - 无法删除/访问文件。出现错误“数值结果超出范围”。如何强制删除文件?
- cuda - 如何在 gprbuild 中使用 nvcc?
- ios - 为什么登录 iTunes Connect 时会显示此合规性筛选页面?
- r - 根据行 ID 将 R 中的值写入 PostgreSQL 表