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). 5 2976
cs wrote: 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,
--
Joerg Jooss jo*********@gmx.net
cs <[rem]casolorz[rem]@hot[rem]mail.com> wrote: 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 Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] wrote: cs <[rem]casolorz[rem]@hot[rem]mail.com> wrote: 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,
did you read my reply to the OP?
Stop doing that ESP thing at once!
;-) ;-)
Cheers,
--
Joerg Jooss jo*********@gmx.net
Joerg Jooss <jo*********@gmx.net> wrote: 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
:)
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
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!
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... cs <[rem]casolorz[rem]@hot[rem]mail.com> wrote: 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 Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kueishiong Tu |
last post by:
I have a network stream which I got from HttpWebResponse and does not support
seeking, How do I find the length of the network stream?
HttpWebResponse* response = dynamic_cast<HttpWebResponse*>...
|
by: Yechezkal Gutfreund |
last post by:
I have been using the following code (successfully) to read Xml formated
text packets from a TCP stream. The output from the server stream consists
of a sequence of well formed Xml documents...
|
by: cs |
last post by:
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).
|
by: Scott |
last post by:
Hi guys,
If I try to call read(), readline(), readtoend() and
there is nothing to read (from a never ending loop for
example) the program seems to continue but it exits the
loop for no apparent...
|
by: Leonardo D'Ippolito |
last post by:
Hi!
I have two .NET win apps that need to communicate on a TCP/IP network.
'App A' must ask 'app B' if it's allowed to do some task, and 'app B'
must authorize or prohibit it.
How can I do...
| |
by: simonrigby_uk |
last post by:
Hi all,
Sorry if this is the incorrect group but I couldn't see anything
directly relevant.
Can someone confirm for me what happens when two network streams are
sent to an application at the...
|
by: A.M-SG |
last post by:
Hi,
I have a ASP.NET aspx file that needs to pass large images from a network
storage to client browser. The requirement is that users cannot have access
to the network share. The aspx file...
|
by: Sir Psycho |
last post by:
Hi,
For some reason, when i step over this code, it returns the full byte
stream im expecting from the server, however when I let it run with no
intervention, it only seems to grab a small chunk...
|
by: cryogeneric |
last post by:
Hello everyone
I'm creating an ASP classic application that let's users download and save PDF files without having to bring them up in the browser. I have successfully used the LoadFromFile ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |