network stream

  • Thread starter Thread starter cs
  • Start date Start date
C

cs

I need to get the position and also seek in a network stream, is there an
easy way to do that? (I am converting some java code so thats the easy
path).
 
cs said:
I need to get the position and also seek in a network stream, is
there an easy way to do that? (I am converting some java code so
thats the easy path).

Quoting MSDN:

"The NetworkStream does not support random access to the network data
stream. The value of the CanSeek property, which indicates whether the
stream supports seeking, is always false; reading the Position property,
reading the Length property, or calling the Seek method will throw a
NotSupportedException."

I'd be surprised if the java.net.InputStream implementation allowed
seeking -- but anyway, I guess one thing you can do is buffer the entire
data received in a MemoryStream and seek within that stream.

Cheers,
 
cs said:
I need to get the position and also seek in a network stream, is there an
easy way to do that? (I am converting some java code so thats the easy
path).

Well, the Position property of a NetworkStream isn't supported, and
neither is Seek. I'm surprised you can do it in Java, to be honest...

Have you considered buffering the contents of the NetworkStream in a
MemoryStream, and then using the Position property on that? (Personally
I find it easier to set Position directly rather than seeking, too, but
YMMV.)
 
Jon said:
Well, the Position property of a NetworkStream isn't supported, and
neither is Seek. I'm surprised you can do it in Java, to be honest...

Have you considered buffering the contents of the NetworkStream in a
MemoryStream, and then using the Position property on that?
(Personally I find it easier to set Position directly rather than
seeking, too, but YMMV.)

Jon,

did you read my reply to the OP?

Stop doing that ESP thing at once!

;-) ;-)

Cheers,
 
Joerg Jooss said:
did you read my reply to the OP?

Stop doing that ESP thing at once!

LOL - I actually wrote my reply this morning, while offline. I've seen
more similar ones though - Daniel and I wrote practically identical
replies to someone within minutes of each other about a week ago though
:)
 
I just took a long hard look at the java code and at the c# code and damm is
it way different, that microsoft convert utility made a mess of it!
 
Back
Top