Named pipe in winows, difference between FILE_FLAG_OVERLAPPED and PIPE_NOWAIT
up vote
1
down vote
favorite
I am using named pipe in windows and confused about the difference between FILE_FLAG_OVERLAPPED
and PIPE_NOWAIT
which are parameters set in CreateNamedPipe
,I set parameters like this.
HANDLE hPipe = CreateNamedPipe(
lpszPipename, // pipe name
PIPE_ACCESS_DUPLEX | // read/write access
FILE_FLAG_OVERLAPPED, // overlapped mode
PIPE_TYPE_MESSAGE | // message-type pipe
PIPE_READMODE_MESSAGE | // message read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // unlimited instances
BUFSIZE * sizeof(TCHAR), // output buffer size
BUFSIZE * sizeof(TCHAR), // input buffer size
PIPE_TIMEOUT, // client time-out
NULL); // default security attributes
the ConnectNamedPipe
return immediately and I get ERROR_IO_PENDING
from GetLastError
.With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_IO_PENDING
.However the MSDN tells:
With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_PIPE_LISTENING.
so, what does nonblocking-wait
mean, PIPE_NOWAIT
or FILE_FLAG_OVERLAPPED
, thanks a lot!
winapi ipc named-pipes overlap
add a comment |
up vote
1
down vote
favorite
I am using named pipe in windows and confused about the difference between FILE_FLAG_OVERLAPPED
and PIPE_NOWAIT
which are parameters set in CreateNamedPipe
,I set parameters like this.
HANDLE hPipe = CreateNamedPipe(
lpszPipename, // pipe name
PIPE_ACCESS_DUPLEX | // read/write access
FILE_FLAG_OVERLAPPED, // overlapped mode
PIPE_TYPE_MESSAGE | // message-type pipe
PIPE_READMODE_MESSAGE | // message read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // unlimited instances
BUFSIZE * sizeof(TCHAR), // output buffer size
BUFSIZE * sizeof(TCHAR), // input buffer size
PIPE_TIMEOUT, // client time-out
NULL); // default security attributes
the ConnectNamedPipe
return immediately and I get ERROR_IO_PENDING
from GetLastError
.With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_IO_PENDING
.However the MSDN tells:
With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_PIPE_LISTENING.
so, what does nonblocking-wait
mean, PIPE_NOWAIT
or FILE_FLAG_OVERLAPPED
, thanks a lot!
winapi ipc named-pipes overlap
It seems the MSDN uses the term "nonblocking mode" when usingPIPE_ NOWAIT
, and the term "overlapped mode" when usingFILE_FLAG_OVERLAPPED
.PIPE_NOWAIT
is "supported for compatibility with Microsoft LAN Manager version 2.0 and should not be used to achieve asynchronous I/O".
– IInspectable
Nov 10 at 11:24
Very different options. FILE_FLAG_OVERLAPPED sets up the socket so it can handle asynchronous I/O, you can call ReadFile() with an OVERLAPPED argument and handle the read completion later. Very common for pipes, unless the traffic rate is very high you want to avoid blocking a thread too much. PIPE_NOWAIT is useful for synchronous I/O, it prevents ReadFile() from blocking if there is no data yet. Repeatedly calling ReadFile() is then required, polling in common terms. Look at a library like boost::asio to take care of the plumbing.
– Hans Passant
Nov 10 at 12:08
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am using named pipe in windows and confused about the difference between FILE_FLAG_OVERLAPPED
and PIPE_NOWAIT
which are parameters set in CreateNamedPipe
,I set parameters like this.
HANDLE hPipe = CreateNamedPipe(
lpszPipename, // pipe name
PIPE_ACCESS_DUPLEX | // read/write access
FILE_FLAG_OVERLAPPED, // overlapped mode
PIPE_TYPE_MESSAGE | // message-type pipe
PIPE_READMODE_MESSAGE | // message read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // unlimited instances
BUFSIZE * sizeof(TCHAR), // output buffer size
BUFSIZE * sizeof(TCHAR), // input buffer size
PIPE_TIMEOUT, // client time-out
NULL); // default security attributes
the ConnectNamedPipe
return immediately and I get ERROR_IO_PENDING
from GetLastError
.With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_IO_PENDING
.However the MSDN tells:
With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_PIPE_LISTENING.
so, what does nonblocking-wait
mean, PIPE_NOWAIT
or FILE_FLAG_OVERLAPPED
, thanks a lot!
winapi ipc named-pipes overlap
I am using named pipe in windows and confused about the difference between FILE_FLAG_OVERLAPPED
and PIPE_NOWAIT
which are parameters set in CreateNamedPipe
,I set parameters like this.
HANDLE hPipe = CreateNamedPipe(
lpszPipename, // pipe name
PIPE_ACCESS_DUPLEX | // read/write access
FILE_FLAG_OVERLAPPED, // overlapped mode
PIPE_TYPE_MESSAGE | // message-type pipe
PIPE_READMODE_MESSAGE | // message read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // unlimited instances
BUFSIZE * sizeof(TCHAR), // output buffer size
BUFSIZE * sizeof(TCHAR), // input buffer size
PIPE_TIMEOUT, // client time-out
NULL); // default security attributes
the ConnectNamedPipe
return immediately and I get ERROR_IO_PENDING
from GetLastError
.With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_IO_PENDING
.However the MSDN tells:
With a nonblocking-wait handle, the connect operation returns zero immediately, and the GetLastError function returns ERROR_PIPE_LISTENING.
so, what does nonblocking-wait
mean, PIPE_NOWAIT
or FILE_FLAG_OVERLAPPED
, thanks a lot!
winapi ipc named-pipes overlap
winapi ipc named-pipes overlap
edited Nov 10 at 9:53
πάντα ῥεῖ
71.4k972134
71.4k972134
asked Nov 10 at 9:46
Gordon
756
756
It seems the MSDN uses the term "nonblocking mode" when usingPIPE_ NOWAIT
, and the term "overlapped mode" when usingFILE_FLAG_OVERLAPPED
.PIPE_NOWAIT
is "supported for compatibility with Microsoft LAN Manager version 2.0 and should not be used to achieve asynchronous I/O".
– IInspectable
Nov 10 at 11:24
Very different options. FILE_FLAG_OVERLAPPED sets up the socket so it can handle asynchronous I/O, you can call ReadFile() with an OVERLAPPED argument and handle the read completion later. Very common for pipes, unless the traffic rate is very high you want to avoid blocking a thread too much. PIPE_NOWAIT is useful for synchronous I/O, it prevents ReadFile() from blocking if there is no data yet. Repeatedly calling ReadFile() is then required, polling in common terms. Look at a library like boost::asio to take care of the plumbing.
– Hans Passant
Nov 10 at 12:08
add a comment |
It seems the MSDN uses the term "nonblocking mode" when usingPIPE_ NOWAIT
, and the term "overlapped mode" when usingFILE_FLAG_OVERLAPPED
.PIPE_NOWAIT
is "supported for compatibility with Microsoft LAN Manager version 2.0 and should not be used to achieve asynchronous I/O".
– IInspectable
Nov 10 at 11:24
Very different options. FILE_FLAG_OVERLAPPED sets up the socket so it can handle asynchronous I/O, you can call ReadFile() with an OVERLAPPED argument and handle the read completion later. Very common for pipes, unless the traffic rate is very high you want to avoid blocking a thread too much. PIPE_NOWAIT is useful for synchronous I/O, it prevents ReadFile() from blocking if there is no data yet. Repeatedly calling ReadFile() is then required, polling in common terms. Look at a library like boost::asio to take care of the plumbing.
– Hans Passant
Nov 10 at 12:08
It seems the MSDN uses the term "nonblocking mode" when using
PIPE_ NOWAIT
, and the term "overlapped mode" when using FILE_FLAG_OVERLAPPED
. PIPE_NOWAIT
is "supported for compatibility with Microsoft LAN Manager version 2.0 and should not be used to achieve asynchronous I/O".– IInspectable
Nov 10 at 11:24
It seems the MSDN uses the term "nonblocking mode" when using
PIPE_ NOWAIT
, and the term "overlapped mode" when using FILE_FLAG_OVERLAPPED
. PIPE_NOWAIT
is "supported for compatibility with Microsoft LAN Manager version 2.0 and should not be used to achieve asynchronous I/O".– IInspectable
Nov 10 at 11:24
Very different options. FILE_FLAG_OVERLAPPED sets up the socket so it can handle asynchronous I/O, you can call ReadFile() with an OVERLAPPED argument and handle the read completion later. Very common for pipes, unless the traffic rate is very high you want to avoid blocking a thread too much. PIPE_NOWAIT is useful for synchronous I/O, it prevents ReadFile() from blocking if there is no data yet. Repeatedly calling ReadFile() is then required, polling in common terms. Look at a library like boost::asio to take care of the plumbing.
– Hans Passant
Nov 10 at 12:08
Very different options. FILE_FLAG_OVERLAPPED sets up the socket so it can handle asynchronous I/O, you can call ReadFile() with an OVERLAPPED argument and handle the read completion later. Very common for pipes, unless the traffic rate is very high you want to avoid blocking a thread too much. PIPE_NOWAIT is useful for synchronous I/O, it prevents ReadFile() from blocking if there is no data yet. Repeatedly calling ReadFile() is then required, polling in common terms. Look at a library like boost::asio to take care of the plumbing.
– Hans Passant
Nov 10 at 12:08
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
PIPE_NOWAIT
mean that Nonblocking mode is enabled on handle. In this mode, ReadFile
, WriteFile
, and ConnectNamedPipe
always completed immediately.
the FILE_FLAG_OVERLAPPED
mean asynchronous mode is enabled on handle. If this mode is enabled, all not synchronous io [1] operations always return immediately.
so FILE_FLAG_OVERLAPPED
vs PIPE_NOWAIT
- this is return immediately vs completed immediately.
completed immediately (which include return immediately ) mean that io operation is already completed when api return. but visa versa not true. if operation return immediately this not mean that operation is completed already. if operation still not completed ntapi return code STATUS_PENDING
. win32 api in such situations usual set last error to ERROR_IO_PENDING
.
exist 3 way determinate when io operation completed in case asynchronous handle mode.
- bind handle to IOCP (via
CreateIoCompletionPort
or
BindIoCompletionCallback
orCreateThreadpoolIo
). as result when
io complete - pointer toOVERLAPPED
which we pass to io call -
will be queued back to IOCP (in caseBindIoCompletionCallback
or
CreateThreadpoolIo
system yourself create IOCP and listen on it
and call our registered callback, when pointer toOVERLAPPED
will
be queued to IOCP) - some win32 api such
ReadFileEx
orWriteFileEx
and all ntapi let
specify APC completion routine which will be called in context of
thread, which begin io operation, when io operation is completed.
thread must do alertable wait in this case. this wait is not
compatible with bind handle to IOCP (we can not use APC routine in
api call if file handle binded to IOCP - system return invalid
parameter error) - we can create event and pass it to api call (via
OVERLAPPED::hEvent
) - in this case this event will be reset by
system when io operation begin and set to signaled state when io
operation is completed. unlike first 2 option in this case we have
no additional context (in face pointer toOVERLAPPED
) when io
operation is completed. usually this is worst option.
[1] exist some io operations which is always synchronous api. for example GetFileInformationByHandleEx
, SetFileInformationByHandle
. but almost io operations is not synchronous io. all this io operations take pointer to OVERLAPPED
as parameter. so if no pointer to OVERLAPPED
in api signature - this is synchronous api call. if exist - usually asynchronous (exception CancelIoEx
for example where pointer to overlapped is related not to current operation but to previous io operation which we want cancel). in particular ReadFile
, WriteFile
, DeviceIoControl
, ConnectNamedPipe
( internally this is call DeviceIoControl
with FSCTL_PIPE_LISTEN
) ) is not synchronous io api
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237751%2fnamed-pipe-in-winows-difference-between-file-flag-overlapped-and-pipe-nowait%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
PIPE_NOWAIT
mean that Nonblocking mode is enabled on handle. In this mode, ReadFile
, WriteFile
, and ConnectNamedPipe
always completed immediately.
the FILE_FLAG_OVERLAPPED
mean asynchronous mode is enabled on handle. If this mode is enabled, all not synchronous io [1] operations always return immediately.
so FILE_FLAG_OVERLAPPED
vs PIPE_NOWAIT
- this is return immediately vs completed immediately.
completed immediately (which include return immediately ) mean that io operation is already completed when api return. but visa versa not true. if operation return immediately this not mean that operation is completed already. if operation still not completed ntapi return code STATUS_PENDING
. win32 api in such situations usual set last error to ERROR_IO_PENDING
.
exist 3 way determinate when io operation completed in case asynchronous handle mode.
- bind handle to IOCP (via
CreateIoCompletionPort
or
BindIoCompletionCallback
orCreateThreadpoolIo
). as result when
io complete - pointer toOVERLAPPED
which we pass to io call -
will be queued back to IOCP (in caseBindIoCompletionCallback
or
CreateThreadpoolIo
system yourself create IOCP and listen on it
and call our registered callback, when pointer toOVERLAPPED
will
be queued to IOCP) - some win32 api such
ReadFileEx
orWriteFileEx
and all ntapi let
specify APC completion routine which will be called in context of
thread, which begin io operation, when io operation is completed.
thread must do alertable wait in this case. this wait is not
compatible with bind handle to IOCP (we can not use APC routine in
api call if file handle binded to IOCP - system return invalid
parameter error) - we can create event and pass it to api call (via
OVERLAPPED::hEvent
) - in this case this event will be reset by
system when io operation begin and set to signaled state when io
operation is completed. unlike first 2 option in this case we have
no additional context (in face pointer toOVERLAPPED
) when io
operation is completed. usually this is worst option.
[1] exist some io operations which is always synchronous api. for example GetFileInformationByHandleEx
, SetFileInformationByHandle
. but almost io operations is not synchronous io. all this io operations take pointer to OVERLAPPED
as parameter. so if no pointer to OVERLAPPED
in api signature - this is synchronous api call. if exist - usually asynchronous (exception CancelIoEx
for example where pointer to overlapped is related not to current operation but to previous io operation which we want cancel). in particular ReadFile
, WriteFile
, DeviceIoControl
, ConnectNamedPipe
( internally this is call DeviceIoControl
with FSCTL_PIPE_LISTEN
) ) is not synchronous io api
add a comment |
up vote
1
down vote
PIPE_NOWAIT
mean that Nonblocking mode is enabled on handle. In this mode, ReadFile
, WriteFile
, and ConnectNamedPipe
always completed immediately.
the FILE_FLAG_OVERLAPPED
mean asynchronous mode is enabled on handle. If this mode is enabled, all not synchronous io [1] operations always return immediately.
so FILE_FLAG_OVERLAPPED
vs PIPE_NOWAIT
- this is return immediately vs completed immediately.
completed immediately (which include return immediately ) mean that io operation is already completed when api return. but visa versa not true. if operation return immediately this not mean that operation is completed already. if operation still not completed ntapi return code STATUS_PENDING
. win32 api in such situations usual set last error to ERROR_IO_PENDING
.
exist 3 way determinate when io operation completed in case asynchronous handle mode.
- bind handle to IOCP (via
CreateIoCompletionPort
or
BindIoCompletionCallback
orCreateThreadpoolIo
). as result when
io complete - pointer toOVERLAPPED
which we pass to io call -
will be queued back to IOCP (in caseBindIoCompletionCallback
or
CreateThreadpoolIo
system yourself create IOCP and listen on it
and call our registered callback, when pointer toOVERLAPPED
will
be queued to IOCP) - some win32 api such
ReadFileEx
orWriteFileEx
and all ntapi let
specify APC completion routine which will be called in context of
thread, which begin io operation, when io operation is completed.
thread must do alertable wait in this case. this wait is not
compatible with bind handle to IOCP (we can not use APC routine in
api call if file handle binded to IOCP - system return invalid
parameter error) - we can create event and pass it to api call (via
OVERLAPPED::hEvent
) - in this case this event will be reset by
system when io operation begin and set to signaled state when io
operation is completed. unlike first 2 option in this case we have
no additional context (in face pointer toOVERLAPPED
) when io
operation is completed. usually this is worst option.
[1] exist some io operations which is always synchronous api. for example GetFileInformationByHandleEx
, SetFileInformationByHandle
. but almost io operations is not synchronous io. all this io operations take pointer to OVERLAPPED
as parameter. so if no pointer to OVERLAPPED
in api signature - this is synchronous api call. if exist - usually asynchronous (exception CancelIoEx
for example where pointer to overlapped is related not to current operation but to previous io operation which we want cancel). in particular ReadFile
, WriteFile
, DeviceIoControl
, ConnectNamedPipe
( internally this is call DeviceIoControl
with FSCTL_PIPE_LISTEN
) ) is not synchronous io api
add a comment |
up vote
1
down vote
up vote
1
down vote
PIPE_NOWAIT
mean that Nonblocking mode is enabled on handle. In this mode, ReadFile
, WriteFile
, and ConnectNamedPipe
always completed immediately.
the FILE_FLAG_OVERLAPPED
mean asynchronous mode is enabled on handle. If this mode is enabled, all not synchronous io [1] operations always return immediately.
so FILE_FLAG_OVERLAPPED
vs PIPE_NOWAIT
- this is return immediately vs completed immediately.
completed immediately (which include return immediately ) mean that io operation is already completed when api return. but visa versa not true. if operation return immediately this not mean that operation is completed already. if operation still not completed ntapi return code STATUS_PENDING
. win32 api in such situations usual set last error to ERROR_IO_PENDING
.
exist 3 way determinate when io operation completed in case asynchronous handle mode.
- bind handle to IOCP (via
CreateIoCompletionPort
or
BindIoCompletionCallback
orCreateThreadpoolIo
). as result when
io complete - pointer toOVERLAPPED
which we pass to io call -
will be queued back to IOCP (in caseBindIoCompletionCallback
or
CreateThreadpoolIo
system yourself create IOCP and listen on it
and call our registered callback, when pointer toOVERLAPPED
will
be queued to IOCP) - some win32 api such
ReadFileEx
orWriteFileEx
and all ntapi let
specify APC completion routine which will be called in context of
thread, which begin io operation, when io operation is completed.
thread must do alertable wait in this case. this wait is not
compatible with bind handle to IOCP (we can not use APC routine in
api call if file handle binded to IOCP - system return invalid
parameter error) - we can create event and pass it to api call (via
OVERLAPPED::hEvent
) - in this case this event will be reset by
system when io operation begin and set to signaled state when io
operation is completed. unlike first 2 option in this case we have
no additional context (in face pointer toOVERLAPPED
) when io
operation is completed. usually this is worst option.
[1] exist some io operations which is always synchronous api. for example GetFileInformationByHandleEx
, SetFileInformationByHandle
. but almost io operations is not synchronous io. all this io operations take pointer to OVERLAPPED
as parameter. so if no pointer to OVERLAPPED
in api signature - this is synchronous api call. if exist - usually asynchronous (exception CancelIoEx
for example where pointer to overlapped is related not to current operation but to previous io operation which we want cancel). in particular ReadFile
, WriteFile
, DeviceIoControl
, ConnectNamedPipe
( internally this is call DeviceIoControl
with FSCTL_PIPE_LISTEN
) ) is not synchronous io api
PIPE_NOWAIT
mean that Nonblocking mode is enabled on handle. In this mode, ReadFile
, WriteFile
, and ConnectNamedPipe
always completed immediately.
the FILE_FLAG_OVERLAPPED
mean asynchronous mode is enabled on handle. If this mode is enabled, all not synchronous io [1] operations always return immediately.
so FILE_FLAG_OVERLAPPED
vs PIPE_NOWAIT
- this is return immediately vs completed immediately.
completed immediately (which include return immediately ) mean that io operation is already completed when api return. but visa versa not true. if operation return immediately this not mean that operation is completed already. if operation still not completed ntapi return code STATUS_PENDING
. win32 api in such situations usual set last error to ERROR_IO_PENDING
.
exist 3 way determinate when io operation completed in case asynchronous handle mode.
- bind handle to IOCP (via
CreateIoCompletionPort
or
BindIoCompletionCallback
orCreateThreadpoolIo
). as result when
io complete - pointer toOVERLAPPED
which we pass to io call -
will be queued back to IOCP (in caseBindIoCompletionCallback
or
CreateThreadpoolIo
system yourself create IOCP and listen on it
and call our registered callback, when pointer toOVERLAPPED
will
be queued to IOCP) - some win32 api such
ReadFileEx
orWriteFileEx
and all ntapi let
specify APC completion routine which will be called in context of
thread, which begin io operation, when io operation is completed.
thread must do alertable wait in this case. this wait is not
compatible with bind handle to IOCP (we can not use APC routine in
api call if file handle binded to IOCP - system return invalid
parameter error) - we can create event and pass it to api call (via
OVERLAPPED::hEvent
) - in this case this event will be reset by
system when io operation begin and set to signaled state when io
operation is completed. unlike first 2 option in this case we have
no additional context (in face pointer toOVERLAPPED
) when io
operation is completed. usually this is worst option.
[1] exist some io operations which is always synchronous api. for example GetFileInformationByHandleEx
, SetFileInformationByHandle
. but almost io operations is not synchronous io. all this io operations take pointer to OVERLAPPED
as parameter. so if no pointer to OVERLAPPED
in api signature - this is synchronous api call. if exist - usually asynchronous (exception CancelIoEx
for example where pointer to overlapped is related not to current operation but to previous io operation which we want cancel). in particular ReadFile
, WriteFile
, DeviceIoControl
, ConnectNamedPipe
( internally this is call DeviceIoControl
with FSCTL_PIPE_LISTEN
) ) is not synchronous io api
answered Nov 10 at 14:17
RbMm
17k11224
17k11224
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237751%2fnamed-pipe-in-winows-difference-between-file-flag-overlapped-and-pipe-nowait%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It seems the MSDN uses the term "nonblocking mode" when using
PIPE_ NOWAIT
, and the term "overlapped mode" when usingFILE_FLAG_OVERLAPPED
.PIPE_NOWAIT
is "supported for compatibility with Microsoft LAN Manager version 2.0 and should not be used to achieve asynchronous I/O".– IInspectable
Nov 10 at 11:24
Very different options. FILE_FLAG_OVERLAPPED sets up the socket so it can handle asynchronous I/O, you can call ReadFile() with an OVERLAPPED argument and handle the read completion later. Very common for pipes, unless the traffic rate is very high you want to avoid blocking a thread too much. PIPE_NOWAIT is useful for synchronous I/O, it prevents ReadFile() from blocking if there is no data yet. Repeatedly calling ReadFile() is then required, polling in common terms. Look at a library like boost::asio to take care of the plumbing.
– Hans Passant
Nov 10 at 12:08