473,671 Members | 2,251 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 2992
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
7352
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
8476
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
8393
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
8917
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
8821
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
8598
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
8670
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2812
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1809
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.