Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Win2003 IIS6 C# ASP.NET VB.NET , +
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....
"java.io.StreamCorruptedException: invalid stream header: 56455249"
 
my code is as below...
string url = "http://www.myserverurl.com";
                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);
                reqst.Flush();
                reqst.Close();
 
I require Stream obj to send data to server as string and not as byte. How to do so?
 
Thanks in advance.
 
Regards,
Rajesh Katare
Posted 24-Jun-11 5:35am
Edited 24-Jun-11 5:58am
(no name)138.5K
v3

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

  Print Answers RSS
0 Maciej Los 295
1 OriginalGriff 273
2 Aajmot Sk 234
3 Marcin Kozub 205
4 Richard MacCutchan 200
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 24 Jun 2011
Copyright © CodeProject, 1999-2014
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