Re: Socket Class Slower Then HTTP Web Request

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Feroze [msft] (ferozed_at_online.microsoft.com)
Date: 03/25/05


Date: Fri, 25 Mar 2005 15:40:08 -0800

Look at this post, which will show you what the suggested way of downloading
is:

http://blogs.msdn.com/feroze_daud/archive/2004/03/30/104440.aspx

-- 
feroze
-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.
See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------
<mwieder@gmail.com> wrote in message
news:1111764670.352222.307260@f14g2000cwb.googlegroups.com...
> Hi - thanks for the suggestions - I understood everything you suggested
> (see new code below) except the comment on the ASCIIEncoding - please
> change th code below to illustarte what you are suggesting there.
> thanks!
>
> public string Send(string HttpRequest)
> {
> m_sock = new Socket(ipe.AddressFamily, SocketType.Stream,
> ProtocolType.Tcp);
>
> m_sock.Connect(ipe);
>
> Encoding ASCII = Encoding.ASCII;
>
> Byte[] ByteGet = ASCII.GetBytes(HttpRequest);
> Byte[] RecvBytes = new Byte[16384];
> m_sock.Send(ByteGet, ByteGet.Length, 0);
> Int32 bytes;
>
> StringBuilder sbDataReceived = new StringBuilder();
>
> do
> {
> bytes = m_sock.Receive(RecvBytes, RecvBytes.Length, 0);
> sbDataReceived.Append(ASCII.GetString(RecvBytes, 0, bytes));
>
> } while (bytes > 0);
>
> m_sock.Shutdown(SocketShutdown.Both);
> m_sock.Close();
>
> return sbDataReceived.ToString();
>
> }
>


Relevant Pages

  • Re: Why does this code work?
    ... If you're suggesting that people shouldn't have to learn the difference ... between reference types and value types, ... AppendData which takes a StringBuilder and appends some data, ... StringBuilder, because people may not be aware that the StringBuilder ...
    (microsoft.public.dotnet.general)
  • Re: Giving an application a window icon in a sensible way
    ... My mistake, then. ... that began with your posting a question and continued -- well, ... This was misinterpreted as suggesting I didn't make the first post. ... That sounded to me like a reference to a specific thread. ...
    (comp.lang.java.programmer)
  • Re: Java and avoiding software piracy?
    ... the NNTP server are missing on GG nearly 12 hours later. ... nothing at all new for the last day in the "usb dongle" thread, ... constructive by suggesting a viable alternative; ... *constructive* suggestion or refrain from posting any criticism at all ...
    (comp.lang.java.programmer)
  • Re: ATTN: Jason Pawloski
    ... On Apr 27 2008 10:22 AM, da pickle wrote: ... posting here, it is even more dangerous to be suggesting otherwise. ... mistakes can be quite injurious. ...
    (rec.gambling.poker)
  • Re: "Dangerous Roads"
    ... >>>Then stop suggesting it. ... I'm afriad your level of posting has descended to the ... >> childish. ...
    (uk.rec.driving)