Wininet 客户端端口 - delphi 2010
当我建立到服务器的套接字连接时,客户端和服务器都打开了套接字。很容易知道服务器端口是什么(因为我使用它来连接到服务器)。但我想在连接到服务器后发现连接的客户端端口。我在 Delphi 2010 应用程序中使用 Wininet 函数。
伪代码:
1 - InternetOpen
2 - 互联网连接
3 - HttpOpenRequest
4 - HttpSendRequestA
5 - 互联网读取文件
6 - ?????? <------ 如何获取客户端端口?
已编辑:
我发现我应该将 InternetQueryOption 与 INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO 一起使用,但我不知道该怎么做。
When I establish a socket connection to a server, both client and server have sockets opened. Its easy to know what is the server port (since I use it to connect to the server). But I would like to discover the client port of the connection after connecting to a server. I am using Wininet functions in a Delphi 2010 application.
Pseudo-code:
1 - InternetOpen
2 - InternetConnect
3 - HttpOpenRequest
4 - HttpSendRequestA
5 - InternetReadFile
6 - ?????? <------ How to get the client port?
Edited:
I have found I should use InternetQueryOption with INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO, but i have no idea how to do that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您关于使用
InternetQueryOption< 的说法是正确的/code>
函数带有
INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO
标志,这将返回INTERNET_DIAGNOSTIC_SOCKET_INFO 结构
在 Delphi 中看起来像这样
,然后您可以编写一个函数来返回套接字信息,
检查此示例应用程序以查看如何使用它。
you are correct about use the
InternetQueryOption
function with theINTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO
flag, this will return aINTERNET_DIAGNOSTIC_SOCKET_INFO Structure
which in Delphi look like this
and then you can wrote a function to return the socket info
check this sample app to see how use it.