Skip to content

messager: multiple sends sometimes disappear at server #1

@twood02

Description

@twood02

First, get the code with git checkout bug-multi-message. This has been modified so the server loops, receiving multiple messages from the client, and the client is set to send three messages in sequence.


When the client sends multiple messages to the server, sometimes the server only prints out the first or second message. Weird!??!

Here the server only prints "first message", even though the client sends 3 different messages ("first message", "message 2", and "message 3"):

$ ./server
listening on port: 1234
Client ip: 127.0.0.1.
Message (34): [first message]
Client disconnected.

## tcpdump showing all three messages (in this case messages 2 and 3 were sent in one packet)
sudo tcpdump -A -i lo0 port 1234
....
22:55:10.366857 IP localhost.64833 > localhost.search-agent: Flags [P.], seq 1:15, ack 1, win 9186, options [nop,nop,TS val 746563681 ecr 746563681], length 14
E..B5h@[email protected]...=<.Q.....#..6.....
,..a,..afirst message.
22:55:10.366874 IP localhost.search-agent > localhost.64833: Flags [.], ack 15, win 9185, options [nop,nop,TS val 746563681 ecr 746563681], length 0
E..4.d@[email protected]....=<...#..(.....
,..a,..a
22:55:10.366878 IP localhost.64833 > localhost.search-agent: Flags [FP.], seq 15:35, ack 1, win 9186, options [nop,nop,TS val 746563681 ecr 746563681], length 20
E..H+$@[email protected]...=<.Q.....#..<.....
,..a,..amessage 2.message 3.

I ran the client a few more time and occasionally it gets all the messages:

Client ip: 127.0.0.1.
Message (14): [first message]
Message (10): [message 2]
Message (10): [message 3]
Client disconnected.

Other times it only gets two of them:

Client ip: 127.0.0.1.
Message (14): [first message]
Message (20): [message 2]
Client disconnected.

Why is this happening? We are using a TCP socket, so we shouldn't be losing any data!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions