473,670 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

network stream

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).
Nov 16 '05 #1
5 2991
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
NotSupportedExc eption."

I'd be surprised if the java.net.InputS tream 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
Nov 16 '05 #2
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.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
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

Nov 16 '05 #4
Joerg Jooss <jo*********@gm x.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.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
cs
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.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
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.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3565
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*> (request->GetResponse()); // Gets the stream associated with the response. Stream* receiveStream = response->GetResponseStream(); int n = receiveStream->Read(responseArray, 0, responseString->Length);
6
7351
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 written to the output stream. We are willing to pay $ to any expert (e.g. MVP) consultant who has to time to help us track down this problem. (we will discuss rates if you can prove your expertise, and problem solving approach).
4
332
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).
8
17326
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 reason. We also can't check the stream for the length, as the network stream doesn't support seek operations
2
5128
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 this kind of communication in a secure way (protected from sniffing)? It would be a very simple protocol. Question, and two possible answers 'yes' or 'no'.
7
3143
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 same time. My scenario is a small server application that listens on a particular TCP port. I am sending streams of data to it via a client app. Inside
3
2331
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 must be the only method that users receive image files.
3
6765
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 on the stream. What am I doing wrong? There is more code than this, but this is the problem code.
6
5870
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 method to perform this feat but not in the manner in which I ultimately want things to be. Currently the PDF's sit on the server itself, but I would like for these to be on a different computer. When I try to set up this scenario, the LoadFromFile...
0
8471
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8815
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8592
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5686
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1795
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.