• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Sending Data Via A Socket As A Stream

Currently I am using a NetworkStream to send data to a server. Now I have a huge problem, because the server recieving the data doesn't using any encoding. There for when I try to send data using the follow, it fails.

networkstream.Write(Encoding.ASCII.GetBytes(strString), 0, Encoding.ASCII.GetByteCount(strString))

Is there any way to send the stream WITHOUT encoding it?
0
dead6re
Asked:
dead6re
  • 3
  • 2
1 Solution
 
gregoryyoungCommented:
It has to be using an encoding of _some_ form ... if it is accepting chars etc at some point the binary data coming accross its socket is being turned into a string on the other end...

0
 
dead6reAuthor Commented:
Okay, The transmission of data is sent to the server. It accepts base64 as the encoding. Currently I encode the string with base64 myself inside the program as a seperate function.

Encode(ByVal strString As String) As String


The transmission is as follows:

e.g.
(INCOMING DATA) <base64data>\n<base64data>\n
(OUTGOING DATA) <base64data>\n<base64data>\n

---

Any possible way to do this?
0
 
gregoryyoungCommented:
well I would probably base64 encode during transmission but .. basically you are just going to take a string .. base64 encode it .. add a \n then convert to bytes to send .. ASCII encoding similar to what you have above should work fine ...

I assume since you are asking that something is not working properly .. have you tried logging the data being sent over the socket using a sniffer etc?



0
 
dead6reAuthor Commented:
I did packet log the program and created a recieve script in another visual basic .net project. The outcome was looking very screwed up.

Ill try with ASCII encoding.
0
 
dead6reAuthor Commented:
Okay, I debugged my base64, and it wasn't working so I have used a different method and it all works now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now