Close
Close window
Peek - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

Sockets

Peek

check for data on a socket

Calling Sequence

Peek(sid)

Parameters

sid

-

valid open socket ID

Description

By default, a read operation on a socket will block until data becomes available. The procedure Peek enables you to test for the presence of data on a socket. This is useful for avoiding the use of timeouts on calls to Sockets[Read] , Sockets[ReadLine] , or Sockets[ReadBinary] .

The procedure Peek never blocks; either the value false or a string is returned immediately.

When Peek is called, it "samples" the data available on the socket without reading it. A string containing the data "sample" is returned. The same data will be available to the next call to Sockets[Read] , Sockets[ReadLine] , or Sockets[ReadBinary] . If no data is available on the socket, then the value false is returned.

Examples

>

withSockets:

>

sidOpenlocalhost,echo:

>

Writesid,Sample data:

>

Peeksid

Sample data

(1)
>

Readsid

Sample data

(2)
>

Peeksid

false

(3)
>

Writesid,Sample data:

>

whilePeeksidfalsedoReadsidenddo

Sample data

(4)
>

Closesid

true

(5)


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /