| |

VerySource

 Forgot password?
 Register
Search
View: 664|Reply: 4

Let's take a look at this situation, do not call OnReceive

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-16 21:30:01
| Show all posts |Read mode
The client derives its own class from CAsyncSocket and overrides the OnReceive function. The server will send out a disconnection detection packet at regular intervals. The client discards the packet. But when the client needs to wait for the server to return data, I use WaitForSingleObject to wait for the event. This event sets a signal state after receiving data in this class. The problem is that it seems that data cannot be received after using WaitForSingleObject (do not call OnReceive). As a result, the program cannot correctly get the data sent by the server. Is there any way to solve it?
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-12-18 17:30:01
| Show all posts
1. The client connects to the server successfully?
2. The server sends data successfully?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-12-18 18:00:01
| Show all posts
All succeeded, but once the wait event is called, the result data itself cannot be received. The event is set to have a signal after the data is received, the result is blocked
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-12-18 23:00:01
| Show all posts
WaitFor... are you calling there?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-12-19 11:15:01
| Show all posts
In a member function of the connection class, OnReceive is also there. Isn't that OK?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list