Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

OVERLAPPED SOCKETS - How to call WSARecv ??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OVERLAPPED SOCKETS - How to call WSARecv ??

    I am trying to figure out how to call this Win API function: WSARecv

    Jose has given us:
    Code:
    'DECLARE FUNCTION WSARecv IMPORT "ws2_32.dll" ALIAS "WSARecv" ( _
    '   BYVAL s AS DWORD _                                   ' __in SOCKET s
    ' , BYREF lpBuffers AS WSABUF _                          ' __in_out LPWSABUF lpBuffers
    ' , BYVAL dwBufferCount AS DWORD _                       ' __in DWORD dwBufferCount
    ' , BYREF lpNumberOfBytesRecvd AS DWORD _                ' __out LPDWORD lpNumberOfBytesRecvd
    ' , BYREF lpFlags AS DWORD _                             ' __in_out LPDWORD lpFlags
    ' , BYREF lpOverlapped AS WSAOVERLAPPED _                ' __in LPWSAOVERLAPPED lpOverlapped
    ' , BYVAL lpCompletionRoutine AS DWORD _                 ' __in LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
    ' ) AS LONG 


    lpBuffers - "A pointer to an array of WSABUF structures. Each WSABUF structure contains a pointer to a buffer and the length, in bytes, of the buffer."

    How do you make a buffer array? Like this?
    Code:
    DIM BUFFER_ARRAY(9) AS WSABUF
    How do you put the buffer array into the API call?
    Do you see any errors or BYVAL issues in this:
    Code:
    RESULT_LONG = WSARecv(ACCEPTING_SOCKET, BUFFER_ARRAY(), 1, nBytesReceived, nFlags, MY_WSAOVERLAPPED, CODEPTR(CompletionRoutine))
    Can't get this to work.

  • #2
    > How do you put the buffer array into the API call?

    Passing BUFFER_ARRAY(0), not BUFFER_ARRAY().

    And also passing the number of elements in the array --10 in the case of DIM BUFFER_ARRAY(9) AS WSABUF--, not 1.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Thanks Jose! I didn't know that.

      Comment

      Working...
      X