SocketReadyQ
✖
SocketReadyQ
tests if there is any data immediately available to read from the specified socket.
Details

- Sockets in SocketReadyQ[…] are specified using SocketObject[…].
- SocketReadyQ returns immediately; unlike Read etc., it does not block waiting for data to become available.
- For numeric values, t is interpreted as having units of seconds. A time Quantity can also be used.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Initially on connection, most websites will not send data until a request is made:

https://wolfram.com/xid/0bh0pmuaocx1i7-3xoguq


https://wolfram.com/xid/0bh0pmuaocx1i7-h1qmhu

Write a request to the socket and wait for up to 10 seconds for the server's response to arrive:

https://wolfram.com/xid/0bh0pmuaocx1i7-n6fayl


https://wolfram.com/xid/0bh0pmuaocx1i7-1ovdk

Open a server socket and connect a client socket to it:

https://wolfram.com/xid/0bh0pmuaocx1i7-o0tua6


Initially, neither of them has any data available:

https://wolfram.com/xid/0bh0pmuaocx1i7-wle1sa

Sending a message to the client makes the socket ready for reading:

https://wolfram.com/xid/0bh0pmuaocx1i7-i9jbx6

After reading the message, there is no more data available:

https://wolfram.com/xid/0bh0pmuaocx1i7-vmohxb


https://wolfram.com/xid/0bh0pmuaocx1i7-rewd6b

Wait for a response using a Quantity as the second argument:

https://wolfram.com/xid/0bh0pmuaocx1i7-1td7cf


https://wolfram.com/xid/0bh0pmuaocx1i7-wc95os

Neat Examples (1)Surprising or curious use cases
Make a simple ping time function, measuring how long it takes for an HTTP response to come back:

https://wolfram.com/xid/0bh0pmuaocx1i7-ba3c50
Ping a host to see how long before it responds:

https://wolfram.com/xid/0bh0pmuaocx1i7-t2u8rj

Request the page multiple times:

https://wolfram.com/xid/0bh0pmuaocx1i7-rufj53

Wolfram Research (2017), SocketReadyQ, Wolfram Language function, https://reference.wolfram.com/language/ref/SocketReadyQ.html.
Text
Wolfram Research (2017), SocketReadyQ, Wolfram Language function, https://reference.wolfram.com/language/ref/SocketReadyQ.html.
Wolfram Research (2017), SocketReadyQ, Wolfram Language function, https://reference.wolfram.com/language/ref/SocketReadyQ.html.
CMS
Wolfram Language. 2017. "SocketReadyQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SocketReadyQ.html.
Wolfram Language. 2017. "SocketReadyQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SocketReadyQ.html.
APA
Wolfram Language. (2017). SocketReadyQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SocketReadyQ.html
Wolfram Language. (2017). SocketReadyQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SocketReadyQ.html
BibTeX
@misc{reference.wolfram_2025_socketreadyq, author="Wolfram Research", title="{SocketReadyQ}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/SocketReadyQ.html}", note=[Accessed: 29-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_socketreadyq, organization={Wolfram Research}, title={SocketReadyQ}, year={2017}, url={https://reference.wolfram.com/language/ref/SocketReadyQ.html}, note=[Accessed: 29-March-2025
]}