Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7792273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:08:06+00:00 2026-06-01T22:08:06+00:00

I read the msdn tutorial for using socket with Windows phone. ( http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=VS.96).aspx )

  • 0

I read the msdn tutorial for using socket with Windows phone. (http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=VS.96).aspx) I arrived to connect me to the server.

This, return me an response 200 ( OK response ) =>

HTTP/1.1 200 OK
Date: Mon, 16 Apr 2012 12:45:46 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny13 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
Last-Modified: Tue, 08 Aug 2006 14:12:09 GMT
ETag: "129a2e5-100000-41a822e23a040"
Accept-Ranges: byte

But I don’t know what to do next…

I connect me to the server, I sent this a “GET Message” for download a file

"GET /dwn/file.txt HTTP/1.1\r\nHost:myHost.com\r\n\r\n"

and After the response ? I have to do what?

If you know a tutorial, sample, or just explication, I would thank you greatly!

this my function =>

private void ProcessReceive(SocketAsyncEventArgs e)
    {
        if (e.SocketError == SocketError.Success)
        {

            response = Encoding.UTF8.GetString(e.Buffer, e.Offset, e.BytesTransferred);
            response = response.Trim('\0');

           // show the response server value. 
            Debug.WriteLine(response.ToString());


            // Data has now been sent and received from the server. 
            // Disconnect from the server
            socket = e.UserToken as Socket;
            socket.Shutdown(SocketShutdown.Send);
            socket.Close();
            clientDone.Set();
        }
        else
        {
            // show error in the debugger.
            response = e.SocketError.ToString();
            Debug.WriteLine(response);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:08:08+00:00Added an answer on June 1, 2026 at 10:08 pm

    Why don’t you use WebClient or something like that ?

    If it’s just for experiencing, you should know that this is not a trivial task. Here are some hints:

    • You will probably not receive the whole HTTP response header + body in one “Receive” call. Remember, a TCP socket is a stream.
    • HTTP Headers are encoded in 7 bit ASCII, not UTF8.
    • HTTP Entity (well, body) encoding depends on headers, and decoding it can be tricky.

    Have fun !

    Edit

    Clarifications (point #1):

            // Data has now been sent and received from the server. 
            // Disconnect from the server
            socket = e.UserToken as Socket;
            socket.Shutdown(SocketShutdown.Send);
            socket.Close();
    

    Why do you shutdown and close the socket now? The response body follows the header in the stream. As I said, there is probably more bytes waiting to be received from the server. Continue to call “receive” until either:

    • There is no more bytes to read (socket is closed by the server)
    • You are sure you’ve read the whole response body (see “Content-Length” or “Transfer-Encoding” headers)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read this MSDN like about it and ran its example. http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.useragent.aspx when I
I read the msdn article about disposing objects in http://msdn.microsoft.com/en-us/library/ee557362(office.14).aspx now I'm really confused
As I read http://msdn.microsoft.com/en-us/library/ms165394.aspx : For VB: Inside the Snippet element, add the References
What are good c++ to C# articles/tutorial or books? I am reading http://msdn.microsoft.com/en-us/magazine/cc301520.aspx and
I'm trying to implement a simple TPH example from http://msdn.microsoft.com/en-us/library/dd793152.aspx . I have two
From the MSDN Article I read I should be using the StringBuilder rather than
I read two MSDN articles on Session state modes in ASP .Net. 1 and
I am studying .net Remoting I've read from MSDN, but in one step I
I have read and practiced the MSDN's Profiler Tutorial . But I couldn't find
So I read MSDN and Stack Overflow. I understand what the Action Delegate does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.