| |

VerySource

 Forgot password?
 Register
Search
View: 1199|Reply: 3

Does the data sent first in the network programming reach the destination first?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-22 13:00:01
| Show all posts |Read mode
One thread:
pthread_mutex_lock
Send data 1
Send data 2
pthread_mutex_unlock
Another thread:
pthread_mutex_lock
Send data 3
pthread_mutex_unlock

Will the client receive data 1 and receive data 3 and then receive data 2?
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-30 20:30:01
| Show all posts
Of course it is possible.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-5 08:00:01
| Show all posts
UDP is possible. TCP is impossible
Reply

Use magic Report

1

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-6 00:15:01
| Show all posts
UDP is possible, but the data sent three times will arrive separately.
TCP is not possible, but the data sent three times may arrive together. That is to say, you may receive the data sent three times in buf at a recv. This is called sticky packets and must be considered when programming.
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