Most of the time it is due to a poor implementation of TCP-IP and the protocol implementation ontop of that.
There can be several causes.
Once the device we talked to could not handle the network traffic, resulting in several TCP-IP retries (part of TCP-IP) and showing the result only after minutes. There was loads of traffic on the network and the device was overloaded with traffic it shouldn't even been listing to. Solution was a router.
It could just as easily be something else.
Please post a screenshot or code snippet that shows your implementation and we can give you pointers.
André
Regards,
André (CLA, CLED)