flat assembler
Message board for the users of flat assembler.

Index > Windows > WSAIoctl, DisconnectEx, WSAID_DISCONNECTEX

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 13260
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 07 Feb 2013, 04:46
hi guys,

need help regarding this,

base on closesocket function in MSDN page,
http://msdn.microsoft.com/en-us/library/windows/desktop/ms737582%28v=vs.85%29.aspx

Paul Sheer wrote:

To flush a sock handle, gracefully close the socket, and release the socket handle in the
background:

DisconnectEx(sock, NULL, 0, 0); // retrieve this function pointer with WSAIoctl(WSAID_DISCONNECTEX).
closesocket(sock);
sock = INVALID_SOCKET; // do not make further use of sock.

Do not use the SO_DONTLINGER or SO_LINGER options.


i attempt to follow his advice because closesocket doesn't seem to work in my case, idk why.

DisconnectEx must be retrieved from WSAIoctl.
Code:
#define IOC_WS2         0x08000000
#define IOC_OUT         0x40000000
#define IOC_IN          0x80000000
#define IOC_INOUT       (IOC_IN | IOC_OUT)
#define _WSAIORW( p1, p2 )  (IOC_INOUT | (p1) | (p2))
#define SIO_GET_EXTENSION_FUNCTION_POINTER  _WSAIORW( IOC_WS2, 6 )
    


so, i build the following
Code:
IOC_WS2                 = 0x08000000
IOC_OUT                 = 0x40000000
IOC_IN                  = 0x80000000
IOC_INOUT               = IOC_IN or IOC_OUT

mov  eax,IOC_INOUT
or   eax,IOC_WS2
or   eax,6
invoke  WSAIoctl,[sock],eax,
    


now i am stuck, because the third param for WSAIoctl is DWORD LPVOID lpvInBuffer, suppose to be value of WSAID_DISCONNECTEX is kinda weird.

Quote:

#ifndef WSAID_DISCONNECTEX
#define WSAID_DISCONNECTEX {0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
typedef BOOL (WINAPI *LPFN_DISCONNECTEX)(SOCKET, LPOVERLAPPED, DWORD, DWORD);
#endif

how am i suppose to define WSAID_DISCONNECTEX ?
Code:
WSAID_DISCONNECTEX dd 0x7FDA2E11
                                 dw 0x8630,0x436F
                                 db 0xA0,0x31,0xF5,0x36,0xA6,0xEE,0xC1,0x57
    


any idea?

references:
http://www.asmcommunity.net/board/index.php?topic=25434.0

http://www.openwatcom.org:4000/@md=d&cd=//&cdf=//depot/openwatcom/bld/w32api/include/ws2def.mh&ra=s&rc=s&c=3UY@//depot/openwatcom/bld/w32api/include/ws2def.mh?ac=64&rev1=1

http://spserver.googlecode.com/svn-history/r133/trunk/spserver/spwin32port.hpp
Post 07 Feb 2013, 04:46
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13260
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 18 Feb 2013, 20:40
just want to say,
i tested the following, and it seems work,

for the socket that after you accept and you want to close them immediately, (reach pool limit or concurrent license limit or any other limit)

accept()
WSAAsyncSelect( FD_CLOSE )
shutdown()
SendMessage to [hwnd] WM_SOCK, just accepted socket value, AL=FD_CLOSE

at FD_CLOSE event
recv()
closesocket()

problem solved =) so far, i see all further incoming sockets close gracefully.
Post 18 Feb 2013, 20:40
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.