({{, (RefLink[SocketWaitNext, paclet:ref/SocketWaitNext])[{(Subscript[socket, 1]),(Subscript[socket, 2]),…}] 
waits until there is data ready to read on any of the (Subscript[socket, i]), then returns that socket.}})

OpenersNotesSection(Spacer1)Details

The (Subscript[socket, i]) are specified as (RefLink[SocketObject, paclet:ref/SocketObject])[…].

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Connect to a site 5 times and measure how long it takes for the first connection to be ready:

socks=Table[SocketConnect["http://exampledata.wolfram.com"],5];

Write a request out on all the sockets and measure how long it takes for at least one of them to get back a request:

WriteString[#,"GET /50states.txt HTTP/1.1 \n\n"]&/@socks;
First@AbsoluteTiming[SocketWaitNext[socks]]

Close the sockets:

Close/@socks;

Open a server socket and connect some clients to it:

server=SocketOpen[Automatic];
clients=Table[SocketConnect[server],5];

Initially, none of the clients are ready:

SocketReadyQ/@clients

Write data to a random client from the server in the local session after a delay:

SessionSubmit[ScheduledTask[WriteString[RandomChoice[server["ConnectedClients"]],DateString[]],{5}]]

Read the data sent to the client once it has been submitted:

AbsoluteTiming[ByteArrayToString[SocketReadMessage[First[SocketWaitNext[clients]]]]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SocketWaitAll, paclet:ref/SocketWaitAll])  ▪  (RefLink[SocketReadyQ, paclet:ref/SocketReadyQ])  ▪  (RefLink[Read, paclet:ref/Read])  ▪  (RefLink[SocketListen, paclet:ref/SocketListen])  ▪  (RefLink[WaitNext, paclet:ref/WaitNext])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Network Programming, paclet:guide/NetworkProgramming])}})}})