2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for open_osfhandle on WSASocket
5 * COPYRIGHT: Copyright 2018 Mark Jansen (mark.jansen@reactos.org)
13 static void run_open_osfhandle(void)
17 SOCKET fd
= WSASocketA(AF_INET
, SOCK_STREAM
, 0, NULL
, 0, 0);
18 ok (fd
!= INVALID_SOCKET
, "Invalid socket\n");
19 if (fd
== INVALID_SOCKET
)
22 type
= GetFileType((HANDLE
)fd
);
23 ok(type
== FILE_TYPE_PIPE
, "Expected type FILE_TYPE_PIPE, was: %lu\n", type
);
25 handle
= _open_osfhandle(fd
, _O_BINARY
| _O_RDWR
);
28 ok(handle
!= -1, "Expected a valid handle (%i)\n", err
);
31 /* To close a file opened with _open_osfhandle, call _close. The underlying handle is also closed by
32 a call to _close, so it is not necessary to call the Win32 function CloseHandle on the original handle. */
41 START_TEST(open_osfhandle
)
44 int iResult
= WSAStartup(MAKEWORD(2, 2), &wdata
);
45 ok(iResult
== 0, "WSAStartup failed, iResult == %d\n", iResult
);