Sending Data Via A Socket As A Stream

Posted on 2006-05-26
Last Modified: 2010-04-23
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?
Question by:dead6re
    LVL 37

    Expert Comment

    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...


    Author Comment

    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:

    (INCOMING DATA) <base64data>\n<base64data>\n
    (OUTGOING DATA) <base64data>\n<base64data>\n


    Any possible way to do this?
    LVL 37

    Accepted Solution

    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?


    Author Comment

    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.

    Author Comment

    Okay, I debugged my base64, and it wasn't working so I have used a different method and it all works now.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now