gpt4 book ai didi

c - 从 Apache 模块获取套接字

转载 作者:行者123 更新时间:2023-11-30 16:24:10 25 4
gpt4 key购买 nike

我需要检索 apache C 模块中的套接字对象。我已阅读文档,但没有找到检索此内容的方法。

但是,我可以获取请求的 apr_sockaddr_t 对象

最佳答案

这是一种方法:

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);

关于c - 从 Apache 模块获取套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53702714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com