【发布时间】:2010-11-14 12:09:34
【问题描述】:
我在 Microsoft 平台 SDK 提供的示例 LSP 中的 WSPSend 函数中获取目标端口号时遇到问题。
这是我正在使用的代码。如下图,不输入if语句。我使用调试功能验证了这一点。
我正在尝试使用目标端口 80 识别此函数内的传出 HTTP 数据包。
int WSPAPI
WSPSend(
SOCKET s,
LPWSABUF lpBuffers,
DWORD dwBufferCount,
LPDWORD lpNumberOfBytesSent,
DWORD dwFlags,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
LPWSATHREADID lpThreadId,
LPINT lpErrno
)
{
INT ret = SOCKET_ERROR;
SOCK_INFO *SocketContext = NULL;
LPWSAOVERLAPPEDPLUS ProviderOverlapped = NULL;
*lpErrno = NO_ERROR;
//
// Find our provider socket corresponding to this one
//
SocketContext = FindAndRefSocketContext(s, lpErrno);
if ( NULL == SocketContext )
{
dbgprint( "WSPSend: FindAndRefSocketContext failed!" );
goto cleanup;
}
// My code starts here!!!
SOCKET app = SocketContext->LayeredSocket;
struct sockaddr FAR name;
int FAR namelen;
getpeername(app, &name, &namelen);
struct sockaddr_in sin;
sin =* (const struct sockaddr_in *) (&name);
if(sin.sin_port == htons(80))
{
// This code is not executed after sending HTTP packets!!
}
}
有什么想法吗?
【问题讨论】:
标签: windows visual-c++ networking winsock winsock-lsp