overlapped-io

Windows NAmed Pipes alternative in Linux

强颜欢笑 提交于 2019-12-10 19:45:05
问题 We are porting existing windows code to Linux. We are using ACE as abstraction layer. We are using windows named pipes for communicating with multiple clients and to perform overlapped operations . What is the equivalent to this in linux. I have checked linux named pipes(FIFO), but they seem to support only one client and server and do not support overlapped IO. Can you guide me regarding this. 回答1: Unix sockets. Essentially, Call socket(PF_UNIX, SOCK_STREAM, 0) . This returns a file

Error with ReadFile and Overlapped

て烟熏妆下的殇ゞ 提交于 2019-12-07 15:45:27
I have a problem with ReadFile and overlapped. first I use ReadFile with overlapped with 0 ZeroMemory(&overlapped ,sizeof(OVERLAPPED)); hDevice = CreateFileW(zwpath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); if(hDevice != INVALID_HANDLE_VALUE){ ret = ReadFile(hDevice, buff, 1024, &numerobyte, &overlapped); } with a for(), I can see the bytes using a printf() for (int n=0; n<sizeof(buff); n++) { printf("0x%02X ", buff[n]); } and now I have one variant with a large number crbig = 322122547 d1 =

Timer that supports overlapped I/O (for IOCP)?

懵懂的女人 提交于 2019-12-04 09:02:49
I need to add timers support in an application based on I/O Completion Ports (IOCP). I would like to avoid the use of a specific thread to manage timers. On Linux, you can create a timer that delivers expiration notifications via a file descriptor (see timerfd.h man), so it's great to use it for example with epoll if your application is based on epoll. On Windows, you can use "waitable timers" with an asynchronous procedure call (ACP) (see http://msdn.microsoft.com/en-us/library/ms686898(v=VS.85).aspx ) If you are interested, kqueue (BSD, Mac OS) supports timers by default (see EVFILT_TIMER).

Named Pipes - Asynchronous Peeking

本小妞迷上赌 提交于 2019-12-03 17:50:18
问题 I need to find a way to be notified when a System.IO.Pipe.NamedPipeServerStream opened in asynchronous mode has more data available for reading on it- a WaitHandle would be ideal. I cannot simply use BeginRead() to obtain such a handle because it's possible that i might be signaled by another thread which wants to write to the pipe- so I have to release the lock on the pipe and wait for the write to be complete, and NamedPipeServerStream doesnt have a CancelAsync method. I also tried calling

Named Pipes - Asynchronous Peeking

寵の児 提交于 2019-12-03 06:23:38
I need to find a way to be notified when a System.IO.Pipe.NamedPipeServerStream opened in asynchronous mode has more data available for reading on it- a WaitHandle would be ideal. I cannot simply use BeginRead() to obtain such a handle because it's possible that i might be signaled by another thread which wants to write to the pipe- so I have to release the lock on the pipe and wait for the write to be complete, and NamedPipeServerStream doesnt have a CancelAsync method. I also tried calling BeginRead(), then calling the win32 function CancelIO on the pipe if the thread gets signaled, but I

Why is the callback given to ReadFileEx() not receiving the correct OVERLAPPED structure?

删除回忆录丶 提交于 2019-12-02 12:48:29
问题 For some reason, my callback isn't receiving the address of the correct OVERLAPPED structure after a call to ReadFileEx . What can cause this? Update -- example: #include <stdio.h> #include <Windows.h> void __stdcall completion_routine( unsigned long dwErrorCode, unsigned long dwNumberOfBytesTransfered, OVERLAPPED *lpOverlapped) { printf("Overlapped = %p\n", lpOverlapped); } int _tmain(int argc, LPTSTR argv[]) { HANDLE hvolume = CreateFile( _T("C:\\Windows\\Notepad.exe"), FILE_READ_DATA, FILE

Why is the callback given to ReadFileEx() not receiving the correct OVERLAPPED structure?

蓝咒 提交于 2019-12-02 07:29:25
For some reason, my callback isn't receiving the address of the correct OVERLAPPED structure after a call to ReadFileEx . What can cause this? Update -- example: #include <stdio.h> #include <Windows.h> void __stdcall completion_routine( unsigned long dwErrorCode, unsigned long dwNumberOfBytesTransfered, OVERLAPPED *lpOverlapped) { printf("Overlapped = %p\n", lpOverlapped); } int _tmain(int argc, LPTSTR argv[]) { HANDLE hvolume = CreateFile( _T("C:\\Windows\\Notepad.exe"), FILE_READ_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL); char tempbuf[512];

hEvent member in OVERLAPPED Win32 structure

时光毁灭记忆、已成空白 提交于 2019-11-30 19:25:00
问题 When asynchronous I/O (or "overlapped" I/O in Win32 jargon) is used, we need to deal with the OVERLAPPED structure and his hEvent member. If the I/O function will delay the read or write operation, we will get an ERROR_IO_PENDING error code, then we will wait the asynchronous operation to complete with a WaitForXxxEvent function, then we will call GetOverlappedResult . However, if the I/O operation is immediately completed, we will not get ERROR_IO_PENDING , and in a read operation our read

Using overlapped IO for console input?

五迷三道 提交于 2019-11-29 07:14:36
I'm attempting to use overlapped IO to read input from the console by opening CONIN$ with the FILE_FLAG_OVERLAPPED flag. However, ReadFile blocks when I use it, even with an OVERLAPPED parameter. I've read some posts reporting that this is a Windows 7 bug. I am using 7 so that could be possible. Here's the code I'm using: // Create a console window AllocConsole(); AttachConsole(GetProcessId(GetModuleHandle(NULL))); HANDLE overlappedConsoleIn = CreateFile(L"CONIN$", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); // Set up the console to

Is there really no asynchronous block I/O on Linux?

隐身守侯 提交于 2019-11-28 16:43:53
Consider an application that is CPU bound, but also has high-performance I/O requirements. I'm comparing Linux file I/O to Windows, and I can't see how epoll will help a Linux program at all. The kernel will tell me that the file descriptor is "ready for reading," but I still have to call blocking read() to get my data, and if I want to read megabytes, it's pretty clear that that will block. On Windows, I can create a file handle with OVERLAPPED set, and then use non-blocking I/O, and get notified when the I/O completes, and use the data from that completion function. I need to spend no