Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3391550
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:48:57+00:00 2026-05-18T03:48:57+00:00

I am having a problem in getting the destination port number in the WSPSend

  • 0

I am having a problem in getting the destination port number in the WSPSend function in the sample LSP provided with Microsoft platform SDK.

Here is the code that I am using. As shown below, the if statement is not entered. I verified this using a debug function.

I am trying to recognize the outgoing HTTP packets inside this function using the destination port 80.

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!!
    }
 }

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:48:57+00:00Added an answer on May 18, 2026 at 3:48 am

    Has getpeername worked? Your code needs to check the return code before using the results.

    If no error occurs, getpeername
    returns zero. Otherwise, a value of
    SOCKET_ERROR is returned, and a
    specific error code can be retrieved
    by calling WSAGetLastError.

    That aside, you need to specify namelen to be the size of your output structure before making this call – that is my bet for what is wrong here, since namelen is not initialized. It’s important to read the WinSock documentation carefully – Windows is riddled with these API usage rules, and you could waste a lot of time if you don’t follow them.

    On call, the namelen parameter
    contains the size, in bytes, of the
    name buffer. On return, the namelen
    parameter contains the actual size, in
    bytes, of the name parameter returned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem getting the root URL with this PHP function I composed.
Having a problem getting a TreeView control to display node images. The code below
I am having a problem getting a list of fields from a query defined
I'm having a problem getting access to a database which lives on a remote
I am having a problem getting my project to link with the PhysX libraries
After having solved the problem of getting the editor to launch when there's a
I having a problem getting a ForeignKey to default to zero, it keeps telling
I'm having a problem getting my data model to work correctly. I have the
I'm having a problem getting this functionality to work. Situation is: User Drags an
Here's my high level problem. I want to read a number max_age_in_secs from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.