Click here to Skip to main content
13,048,584 members (93,565 online)
Rate this:
Please Sign up or sign in to vote.
Dear Developer,

I am trying to request to Java Server Socket but they are unable to receive my data_string (data="ABC").

They receive with error....
" invalid stream header: 56455249"

my code is as below...
string url = "";
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                string proxy = null;
                string data = "ABC";
                byte[] buffer = Encoding.UTF8.GetBytes(data);
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = buffer.Length;
                req.Proxy = new WebProxy(proxy, true);
                req.CookieContainer = new CookieContainer();
                Stream reqst = req.GetRequestStream(); // add form data to request stream 
                reqst.Write(buffer, 0, buffer.Length);

I require Stream obj to send data to server as string and not as byte. How to do so?

Thanks in advance.

Rajesh Katare
Posted 24-Jun-11 4:35am
Updated 24-Jun-11 4:58am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 24 Jun 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100