0

I'm writing tcp worker on raw sockets, which simply exchanges http traffic with server. Using raw sockets is, unfortunately, obligatory. So far on the output there is a byte[] array that looks this way:

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/html; charset=utf-8
Date: Thu, 21 Mar 2013 00:58:11 GMT
Transfer-Encoding:  chunked
Connection: keep-alive
Connection: Transfer-Encoding


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en" xml:lang="en" 
xmlns="http://www.w3.org
...

and so on. Question is - can I somehow convert this byte[] array (or its string representation, or any other) into HttpWebResponse? Or maybe there's a way to pass sockets as a stream to WebResponse?

Desperate for any answer, Dolla

2
  • The manual says: "You should never directly create an instance of the HttpWebResponse class. Instead, use the instance returned by a call to HttpWebRequest.GetResponse". I think the class isn't intended to parse arbitrary HTTP responses. I'd also do that and really ditch sockets, because you really don't want to re-implement an HTTP client. Why the sockets only limitation?
    – CodeCaster
    Mar 21, 2013 at 11:39
  • Well, maybe you could suggest any other option on how to use ipv6 over ipv4 through .Net? So far I understand - you can create Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IPv6); It'll give you a protocol 41 - ipv4 header with "Next header = IPv6". Everything that is after this ipv4 header (ipv6 header, tcp header, data) should be constructed manually. Do I miss something? =)
    – Dolla Dora
    Mar 21, 2013 at 18:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.