stream

Unlocking a lock from a thread which doesn't own it, or redesigning to avoid this?

I have an archive object which manages various byte arrays and hands out InputStreams and OutputStreams for reading and writing them. Each byte array has an associated ReentrantReadWriteLock. The constructor of the subclass of InputStream which the archive produces acquires the lock for the relevant data, while close() releases the loc...

C#: Implementing NetworkStream.Peek?

Currently, there isn't a NetworkStream.Peek method in C#. What is the best way of implementing such a method which functions just like NetworkStream.ReadByte except that the returned byte is not actually removed from the Stream? ...

Efficient way to stream Webcam from client to a server C#

Hi, I've set up a custom tcp connection between my client and the server. I'm making a simple chat program. So far the users are able to talk to each other and send files. I'm adding a webcam chat and I've used AForge.Net for grabbing the frames from my webcam. But sending these captured frames from the client to the server is taking t...

GZipStream, how correctly read from GZipStream

I have some code writen by me in C# string host = new Uri(_url).Host; IPHostEntry ipAddress = Dns.GetHostEntry(host); IPEndPoint ip = new IPEndPoint(ipAddress.AddressList[0], 80); using (Socket s = new Socket(ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) { s.Connect(ip); ...

stream video from the server . {iPhone SDK}

hi . i trying to stream video with static IP : http://38.117.88.148/GemTVLink via iphone . can you show me some information and how could implement this > ? i see apple video stream app and it seems can show only .mp4 movie ? iam i right !? i want my app load the http addres and play movie thats it . this link works on meida player ! ...

Problem with named constructor with istream as argument

Hi, I'm trying to create a named constructor for my class Matrix, with an input as a stream from which I can read the values for the initialization. #include <istream> // ... class Matrix { public: Matrix(int); // some methods static Matrix *newFromStream(istream&); private: int n; std::valarray< Cell > data; }; ...

Overwriting, Saving, Using Stream. Are they really different?

I want to make a file unusable. Does it really make sense if i overwrite it? Is there a difference between overwriting, Using stream , Saving or using text append? Note: I want to delete the file afterwards and avoid recovery. ...

CMSSignedDataStreamGenerator hash does not match.

Hi! I`m writing an application that signs and envelopes data using BouncyCastle. I need to sign large files so instead of using the CMSSignedDataGenerator (which works just fine for small files) I chose to use CMSSignedDataStreamGenerator. The signed files are being generated but the SHA1 hash does not match with the original file. Co...

Write StringBuilder to Stream

What is the best method of writing a StringBuilder to a System.IO.Stream? I am currently doing: StringBuilder message = new StringBuilder("All your base"); message.Append(" are belong to us"); System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.Text.ASCIIEncoding encoding = new ASCIIEncoding(); stream.Write(encoder.Ge...

Unit Testing a Class That Uses the File System

I have a class that outputs a simple report file. It reads some record ID numbers from an XML file: each one used for finding a matching record stored in a database. It then writes out each record's details to a CSV file. I am wondering - what is the best way to organise it so that it is easy to test, yet follows the principles of encap...

C# Cannot implicitly convert type 'string' to 'System.IO.StreamReader

What i'm trying to do is open every text file in a directory, read it line by line, and if it matches a specific content, do a regex and output it to a result. For some reason my text files ended up being in unicode...., not sure dont know why. So I was able to work around that but I cant work around the stream reader issue i'm having....

Create Zip file from stream and download it

I have a DataTable that i want to convert it to xml and then zip it, using DotNetZip. finally user can download it via Asp.Net webpage. My code in below dt.TableName = "Declaration"; MemoryStream stream = new MemoryStream(); dt.WriteXml(stream); ZipFile zipFile = new ZipFile(); zipFile.AddEntry("Report.xml", "", s...

How to redirect a System.Windows.Controls.TextBox input to a stream?

I tried: private void textBox1_KeyDown(object sender, KeyEventArgs e) { streamWriter.Write(e.Key.ToString()); } But I don't know how to convert a Key to string correctly. I also tried: private void textBox1_TextInput(object sender, TextCompositionEventArgs e) { streamWriter.Write(e.Text); } But this event is not called. The...

How to implement a poor man's DRM solution

I've been tasked with securing video content for an intranet client/server solution. There seams to be a couple of DRM solutions out there, but most of them have various draw backs for us. Cost is a huge factor. Maintaining the "keep honest people honest" philosophy, I was asked if it would be possible to obfuscate the files on the se...

Java URL problem ?

Greetings all, I am trying to download 'gz' file using URL class .Code snippet is as: URL url = new URL("ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb132l.ent.gz"); InputStream conn = new GZIPInputStream(url.openStream()); But it throws the error: Exception in thread "main" java.net.UnknownHostException: ftp.wwpdb.o...

Using .NET classes to communicate with a USB HID

Are there any USB developers out there who use .NET? I know one way of communicating with USB HID device is creating wrappers to the Windows API's like CreateFile, WriteFile and ReadFile. But I am wondering does anyone know if you can use any of the .NET classes to do the same thing. I am certain that I will still have to use some of th...

How to take a stringbuilder and convert it to a streamReader?

How to take a stringbuilder and convert it to a stream? SO my stringbuilder has to be converted into a : StreamReader stream = ???? Update I tried using a stringreader like: StringReader sr = new StringReader(sb.ToString()); StreamReader stream = new StreamReader(sr); but that doesn't work? ...

How to get client IP from java server through xinetd ?

Hi, I am running a small java server through xinetd superserver. I'd like to get the originating client IP but I can't because streams are between xinetd and java (stin/stdout). Does somebody know how to get the client IP, without looking to xinetd logfile ? (seems a bad solution to me) Thanks ! ...

.NET 3.5 C# TcpClient Reading Issues (Segment loss)

...

Simulcast a .NET Stream

First off I want to be clear that I am not referring to simulcasting a TCP/IP stream, I want to take the output of a c# stream and have it go to multiple destations. For example if I had a FileStream(fs) and a MemoryStream(ms) and a FtpStream(ftps) and did something like ... SuperStreamWriter ss = new SuperStreamWriter(fs, ms...