io

Using overlapped IO for console input?

佐手、 提交于 2020-01-20 05:03:25
问题 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

multithread read from disk?

北城余情 提交于 2020-01-20 04:31:25
问题 Suppose I need to read many distinct, independent chunks of data from the same file saved on disk. Is it possible to multi-thread this upload? Related: Do all threads on the same processor use the same IO device to read from disk? In this case, multi-threading would not speed up the upload at all - the threads would just be waiting in line. (I am currently multi-threading with OpenMP.) 回答1: Yes, it is possible. However: Do all threads on the same processor use the same IO device to read from

Netty服务器端代码,高并发

大兔子大兔子 提交于 2020-01-20 00:39:18
package import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.logging.LogLevel; import io.netty.handler.logging.LoggingHandler; import io.netty.util.concurrent.DefaultThreadFactory; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; public class

Closing Reader/Stream in Java [duplicate]

笑着哭i 提交于 2020-01-17 04:32:09
问题 This question already has an answer here : How can I fix an “IOException: Stream closed” exception using System.in? (1 answer) Closed 4 years ago . In my code I have to read user input from console: class Demo { //...some code public String readUserInput() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String userInput = reader.readLine(); reader.close(); return userInput; } } On first time when I use method readUserInput() on Demo object

How to read a cell value from Excel that contains a function in C#

女生的网名这么多〃 提交于 2020-01-17 04:23:09
问题 I am writing a C# application that reads data from an Excel file. Everything was running smoothly until I attempted to read from a cell that used a formula. I am pulling data from the sheet and trying to add the cumulative quantity, so in a loop, I'm using: cntr = Cell(row, column); NOTE: I'm paraphrasing rather than copy my actual code. Anyways, if the actual cell value contains a number, this works, but if the cell contains a function, it returns the string "=SUM(A1:A5)" and I'm not sure

Is it correct to check if the number of items read is less than requested, rather than 0, in fread(3)?

喜欢而已 提交于 2020-01-17 03:50:06
问题 I'm a beginner to C. I was wondering if it correct to check if the return value of fread(3) (which is the number of items read) is less than the number requested, rather than just 0, to detect EOF. For example, say you have #include <stdio.h> int main(void) { unsigned char buffer[1024]; while (fread(buffer, 1, sizeof(buffer), stdin) == sizeof(buffer)) { printf("%s\n", "Not EOF yet"); } printf("%s\n", "At EOF"); return 0; } Is this correct? Should the check for == sizeof(buffer) be != 0

Storage devices, file transfer and copy operation logic

删除回忆录丶 提交于 2020-01-17 02:41:13
问题 I am trying to create a file copy utility which should work as a replacement of the standard windows file copying process. The main reason to do so is to add copy/move queue support and hopefully some sort of optimisation by enabling multiple file transfers only when the file transfers would not involve the same destination physical media(You know how the overall transfer rate drops when there are multiple transfers going on with the same destination media?) I would like to clarify that I

C strings from text file

我们两清 提交于 2020-01-16 19:56:07
问题 I am new to C programming language. How do you search a particular string from a text file and make them into array, then produce a single string from those array? text file: name1,name2,name3,type1,g1,g2,g3 name1,last1,last2,type2,g4,g6,g7 foo1,foo2,foo3,type3,gx,g3,g5 foo1,doo1,doo2,type4,g1,gt,gl The output should be in 1 string, not separated so if let's say it is printf("%s", strings); It gives output like: 2 records found Name: name1,name2,name3 type: type1 g1 type: g1 g2 type: g2 g3

Multipage Tiff write in MATLAB doesn't work

﹥>﹥吖頭↗ 提交于 2020-01-16 18:46:34
问题 I'm reading in a Tiff using the below function, which works fine, but when I try to use my write function to write that same Tiff back to a different file, it's all 255's. Does anyone know how to fix this? Thanks, Alex. function Y = tiff_read(name) % tiff reader that works info = imfinfo(name); T = numel(info); d1 = info(1).Height; d2 = info(1).Width; Y = zeros(d1,d2,T); for t = 1:T temp = imread(name, t, 'Info',info); Y(:,:,t) = temp(1:end,1:end); end % Tiff writer that doesn't work function

Write dynamically allocated structure to file

送分小仙女□ 提交于 2020-01-16 13:21:07
问题 Suppose we have following structure: struct Something { int i; }; If I want to write in a file any data of this type(dynamically allocated), I do this: struct Something *object = malloc(sizeof(struct Something)); object->i = 0; // set member some value FILE *file = fopen("output_file", "wb"); fwrite(object, sizeof(struct Something), 1 file); fclose(file); Now, my questions: How we do this with a structure what contains pointers? I tested using same method, it worked fine, data could been read