read

C# file read/write fileshare doesn't appear to work

Hi, My question is based off of inheriting a great deal of legacy code that I can't do very much about. Basically, I have a device that will produce a block of data. A library which will call the device to create that block of data, for some reason I don't entirely understand and cannot change even if I wanted to, writes that block of...

Perl - Win32 - How to do a non-blocking read of a filehandle from another process?

I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this: sub _read_from_client { my ($file_handle) = @_; while (my $line = <$file_handle>) { print ST...

How to create a buffer for reading socket data in C

Using C / C++ socket programming, and the "read(socket, buffer, BUFSIZE)" method. What exactly is the "buffer" I know that char and byte are the same thing, but does it matter how many elements the byte array has in it? Does the buffer need to be able to hold the entire message until the null character? ...

Stack memory read

Hi, With the following piece of code: typedef struct { char fileName[ 1024]; time_t deleteTime; } file_item_t; .... .... setEntry(char *fileName) { file_item_t file; memset( &file, 0x00, sizeof( file_item_t )); memcpy( file.fileName, fileName, sizeof( file.fileName ) - 1 ); ... ... ...

Haskell: Inserting every line from a file into a list

I'm currently working on project with Haskell, and have found myself some trouble. I'm supposed to read and insert into a list each line in a "dictionary.txt" file, but I can't seem to do so. I've got this code: main = do let list = [] loadNums "dictionary.txt" list loadNums location list = do inh <- openFile location ReadM...

Ways to save enums in database

Hey guys. I am wondering what the best ways to save enums into a database is. I know there are name() and valueOf() methods to make it into a String back. But are there any other (flexible) options to store these values? Is there a smart way to make them into unique numbers (ordinal() is not safe to use)? Any comments and suggestions...

Display imagenames

Hello, I would like to display the names of the images in an imagemap. In other words: read, in a loop, the content of a map. Jac ...

SQL DataReader missing a row in loop

When running the following code it leaves out one row. When I do a files.Count it says there are 4 rows but there is no data stored for the 4th row. When I run the stored procedure from within SQL Manager it returns all 4 rows and all the data. Any help? List<File> files = new List<File>(); SqlConnection active_c...

Why does the following print 'Resource temporarily unavailable'?

Why does the following code print ‘read(): Resource temporarily unavailable’ 80% of the time? That is the EAGAIN code, which is the same as WOULD BLOCK which means there is no data waiting to be read, but select is returning 1 saying there is data (tested in Linux): #include <time.h> #include <unistd.h> #include <stdio.h> #include <stri...

MemoryStream.Read doesn't copy bytes to buffer - c#

I don't really get it and it's driving me nuts. i've these 4 lines: Image img = Image.FromFile("F:\\Pulpit\\soa.bmp"); MemoryStream imageStream = new MemoryStream(); img.Save(imageStream, ImageFormat.Bmp); byte[] contentBuffer = new byte[imageStream.Length]; imageStream.Read(contentBuffer, 0, contentBuffer.Length); when debugging i ca...

How can I read and manipulate CSV file data in C++?

Pretty self-explanatory, I tried google and got a lot of the dreaded expertsexchange, I searched here as well to no avail. An online tutorial or example would be best. Thanks guys. ...

Fast read/write from file in delphi

I am loading a file into a array in binary form this seems to take a while is there a better faster more efficent way to do this. i am using a similar method for writing back to the file. procedure openfile(fname:string); var myfile: file; filesizevalue,i:integer; begin assignfile(myfile,fname); filesizevalue:=GetFileSize(fn...

Blocking read from FIFO via ifstream object

I open a FIFO file as ifstream. As soon as the object is created the thread is blocked until I send something into the FIFO (which is OK for me). I then call getline() to get the data from stream. How do I read-block the thread again until more data is written into FIFO file? Thanks ...

Read constant UDP stream in php

how do i go about reading data being sent almost constantly to my server. the protocol is udp. if i try to read in a while(1) loop, i dont get anything. it seems like the read will only echo once all the reading is done. so it waits till the loop is done reading which it will never be. i want the socket_read to echo immediately when it g...

variable length packets in php

I am receiving packets sent to my server through UDP. I am using socket_read to read the data and it is coming along just fine. I have run into an error however. The length parameter to socket_read in my case is NOT always the same. The length of the data can range anywhere from 50-150 bytes. One thing that remains constant is that the d...

C/C++ read a byte from an hexinput from stdin

Hi.. Can't exactly find a way on how to do the following in C/C++. Input : hexdecimal values, for example: ffffffffff... I've tried the following code in order to read the input : uint16_t twoBytes; scanf("%x",&twoBytes); Thats works fine and all, but how do I split the 2bytes in 1bytes uint8_t values (or maybe even read the first ...

How to open .ttcn file using C file open functions?

I am working on TTCN-3 (Testing and Test Control Notation) scripting language. I wanted to prepare on guideline checker for this code files. For that I want to read lines of TTCN-3 script file( some thing like file.ttcn ) one by one into a buffer. But for me fopen / sopen / open / fgetc / fscanf are not able to work properly and are not...

Unexpected result from HttpURLConnection - reading remote binary file.

I'm trying to read a remote binary file (say, image) from internet like this: HttpURLConnection connection = (HttpURLConnection) myUrl.openConnection(); //myUrl - URL object pointing for some location if(connection.getResponseCode() == 200){ File temp = File.createTempFile("blabla", fileName); //fileName - string name of file Fi...

Read URL to string Java with cookies

Hi, I need to read from an URL to String, and this is not a problem, but some sites demand for cookies to be enabled to provide content. So I need a way to get a content even if the cookies need to be accepted? Cheers ...

Playback large files on Windows Media Player during download

Hi, My question is about writing a video file to the hard drive that is being downloaded from the network and playing it at the same time using Windows Media Player. The file is pretty big and will take awhile to download. It is necessary to download it rather than just stream it directly to Windows Media Player. What happens is that, ...