![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Re: Reading a NetworkStream Peter Bradley <p.bradley@xxxxxx> wrote: Quote: > I wonder if anyone can help me out? > > I'm trying to implement an EPP (rfc4934 and rfc4930) client. So far > I've managed to connect and authorise using an X509 Certificate. This > should elicit a <greeting> response from the server, and it's the > reading of this response that is giving me a bit of grief. Note that in RFC 4934 I can't see anything suggesting it will be in ASCII - just that it's XML. Might it be UTF-16 encoding? Using BitConverter directly is definitely a bad idea - the RFC says it will be in big endian format. I have an EndianBitConverter which lets you specify endianness as part of MiscUtil: http://pobox.com/~skeet/csharp/miscutil But yes, that number looks rather large. -- Jon Skeet - <skeet@xxxxxx> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet C# in Depth: http://csharpindepth.com |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Reading a NetworkStream Peter Bradley <p.bradley@xxxxxx> wrote: Quote: Quote: > > Is there a public server we can easily contact to try this out? > I forgot you'd need a certificate in order to connect to the server. If > that's a problem I'll see if I can get permission to supply you with the > certificate I've been using. you could get me the certificate, I'll try to take a look tomorrow. -- Jon Skeet - <skeet@xxxxxx> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet C# in Depth: http://csharpindepth.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Reading a NetworkStream Jon Skeet [C# MVP] wrote: Quote: > > I haven't been able to look at the problem tonight, I'm afraid - but if > you could get me the certificate, I'll try to take a look tomorrow. > I'll try to get the certificate to you tonight (say in about 9 or 10 hours). I'm sure it's my stream reading code that's up the spout. This is the first time I've written code like this. Usually I'm doing business rules or Active Directory coding in .NET remote objects or Web services. So I may well be making some really elementary mistakes. Cheers Peter |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Reading a NetworkStream Jon Skeet [C# MVP] wrote: Quote: > > I haven't been able to look at the problem tonight, I'm afraid - but if > you could get me the certificate, I'll try to take a look tomorrow. > I had an epiphany moment. I think I know what the problem is. I'm reading the response from the server using the NetworkStream associated with the TcpClient. That's fine, except that this is a secure stream using SSL, so what I'm looking at is the encrypted data. What I need to do is to create an SslStream from the Network stream and then read from that: // Read the response from the server int bytesRead = sslStream.Read(buffer, 0, buffer.Length); // Convert the received bytes into a string string response = System.Text.Encoding.ASCII.GetString (buffer, 0, bytes); OK, so I still have the business of the first 4 bytes to sort out, but if I'm right on this, that shouldn't be much of a problem. I'll let you know how I get on. Thanks Peter |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Reading a NetworkStream Peter Bradley <pbradley@xxxxxx> wrote: Quote: > I had an epiphany moment. I think I know what the problem is. I'm > reading the response from the server using the NetworkStream associated > with the TcpClient. That's fine, except that this is a secure stream > using SSL, so what I'm looking at is the encrypted data. ![]() Quote: > What I need to > do is to create an SslStream from the Network stream and then read from > that: Quote: > // Read the response from the server > int bytesRead = sslStream.Read(buffer, 0, buffer.Length); > > // Convert the received bytes into a string > > string response = System.Text.Encoding.ASCII.GetString (buffer, > 0, > bytes); > > OK, so I still have the business of the first 4 bytes to sort out, but > if I'm right on this, that shouldn't be much of a problem. -- Jon Skeet - <skeet@xxxxxx> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet C# in Depth: http://csharpindepth.com |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Reading a NetworkStream Peter Bradley <p.bradley@xxxxxx> wrote: Quote: > Yep. It all works swimmingly now. Amazing how explaining the problem > to someone else makes you realise what you're messing up. isn't even listening, and by the time they say, "I'm sorry, were you talking to me?" I've realised where the problem is ![]() Quote: > I didn't use your EndianBitConverter in the end. I just checked whether > we were in little endian context and if so, reversed the byte array. > Crude, but effective. Quote: > My grateful thanks for your help - and your sympathetic ear. > > ![]() up the solution. -- Jon Skeet - <skeet@xxxxxx> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet C# in Depth: http://csharpindepth.com |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| not reading my 120g only reading 24g | Drivers | |||
| Reading | Vista mail | |||
| Reading DVD Ram | Vista General | |||
| reading dvd | Vista music pictures video | |||
| reading CD-R | Vista General | |||