CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    Join Date
    Jun 2009
    Posts
    87

    Re: ASyncSocket Receive Problem

    Thank you Mr Mike,

    I dint called more than once Receive() in OnReceive().
    One small information who is calling the OnReceive()?
    1.System commands
    2.Socket event.
    What is the behind story of AsyncSocket,OnReceive() and Receive() methods?

    Thanks,
    Bharath.

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: ASyncSocket Receive Problem

    Victor Nijegorodov

  3. #18
    Join Date
    Jun 2009
    Posts
    87

    Re: ASyncSocket Receive Problem

    Quote Originally Posted by VictorN View Post
    I studied that articals. Even though i didn't find my problem.

  4. #19
    Join Date
    Jun 2005
    Posts
    315

    Re: ASyncSocket Receive Problem

    Have you verified server operation by using a protocol analyser like WireShark?

  5. #20
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: ASyncSocket Receive Problem

    Quote Originally Posted by bharathkumarreddy.s View Post
    ... I dint called more than once Receive() in OnReceive().
    Then why is it that you stated that you "maintain[ed] in loop" "if coming data is greater than 4096"?

    Never mind, please don't bother to answer.

    Please show your code for send and receive, as mentioned by VictorN above.

    One small information who is calling the OnReceive()?
    1.System commands
    2.Socket event.
    What is the behind story of AsyncSocket,OnReceive() and Receive() methods?
    The details are complex, but the basic idea is this: When there is a new socket event (such as the arrival of new data in the incoming buffer), Windows converts the event into an ordinary Windows message which it posts to the application's message queue. In the MFC message loop, when it encounters one of these messages, the MFC framework converts it into a call to the appropriate virtual function, such as a call to your implementation of the virtual OnReceive() function.

    These details are explained in the links that VictorN gave you.

    Mike
    Last edited by MikeAThon; April 29th, 2010 at 01:28 PM.

  6. #21
    Join Date
    Jun 2009
    Posts
    87

    Re: ASyncSocket Receive Problem

    Quote Originally Posted by MikeAThon View Post
    You should never call Receive() more than once in a single OnReceive() handler. It's incorrect to call Receive() in a loop. Call Receive() exactly once. According to the Winsock and CAsyncSocket framework, if more data is available in the buffer after the call to Receive(), the framework will generate another call to OnReceive at some indeterminate time in the future. The remainder of the buffer can be obtained in the second call to OnReceive (or at least some more of the buffer can be drained).

    Mike

    PS: And VictorN is correct: it's hard to diagnose further without seeing your code for both sender and receiver.
    Thank you.

  7. #22
    Join Date
    Jun 2009
    Posts
    87

    Re: ASyncSocket Receive Problem

    Quote Originally Posted by jeron View Post
    Have you verified server operation by using a protocol analyser like WireShark?
    Thank you jeron,

    I solved my problem. here the problem is java socket outputstream writeBytes();
    I just changed this method to write(data.getByteArray());

    Thank you for all of you,
    special thanks to VictorN.

  8. #23
    Join Date
    Jun 2009
    Posts
    87

    Re: ASyncSocket Receive Problem

    Quote Originally Posted by VictorN View Post
    It's hard to say you more without seeing your actual code (for both sender and receiver)
    I solved my problem, problem with java socket outputstream WriteBytes().
    I solved that with replacing that method with write(data.getByteArray())

    Thank you very much mr.VictorN.

  9. #24
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: ASyncSocket Receive Problem

    You are welcome!
    Victor Nijegorodov

  10. #25
    Join Date
    Jun 2009
    Posts
    87

    Re: ASyncSocket Receive Problem

    VictorN please help me how to find Application crash?
    I wrote another thread regarding that problem,i din't find and reply from more than 5 days.
    pls, reply me.


    Thanks,
    Bharath

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured