Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
Sockets[ReadBinary] - ネットワーク接続からのバイナリデータの読み込み
使い方
ReadBinary(a, sid)
パラメータ
a - hardware データ型の rtable
sid - 有効な開かれたソケット ID
説明
Maple の文字列はエンコードされたバイナリデータ( null バイトを含む)の使用を許さないため、このようなデータの伝達を可能にするために必要なアプリケーションとして、Sockets[Read] とは異なるインタフェースが求められます。手続き ReadBinary を用いることで、この目的が達成されます。
手続き ReadBinary の1つめの引数 a は、hardware rtable でなくてはなりません; これは、以下のデータ型のいずれかを意味します:
integer[ 1 ] integer[ 2 ] integer[ 4 ] integer[ 8 ] float[ 4 ] float[ 8 ]
rtable a に、添え字付きの関数を使用するべきでありません。また storage パラメータに、rectangular 以外のものを設定するべきではありません。
データ型が integer[1] 以外のものである場合には、読み込まれるデータは指示されたデータ型に従った構造として取り扱われ、各 ``record'' はホストのバイト次数に変換されます。例えば、受け渡される rtable のデータ型が float[4] であるならば、各 4 バイトの浮動小数点数は、Network Byte Order から Host Byte Order に変換されます。
ReadBinary は、2つめの引数としてソケット ID sid を受け付けます。パラメータ sid は、どこからそのデータを読み込むかを表す、ネットワーク接続を指定します。
ReadBinary は、rtable a で可能なスペースの全体量まで、できる限り多くのデータをソケット接続から読み込もうと試みます。実際に読み込まれたデータのバイト数が返されます。
注意: ReadBinary に渡された rtable が収容できるよりも、より多くのデータがソケット上で利用可能となることもあります。ひとたび rtable が一杯になってしまうと、ReadBinary は、データを消費するその後の呼び出しについて、ソケット上へ読み込めないデータを残して、戻ることになります。
rtable a を満たすために、ソケット上にある不十分なデータを利用することも可能です。
例
with( Sockets ): s := Open( "localhost", "echo" );
Write( s, "Hello" );
a := Array( 1 .. 10, 'datatype' = 'integer'[ 1 ] );
ReadBinary( a, s );
a;
convert( convert( a, 'list' ), 'bytes' );
Close( s );
時刻サービス (RFC 868) は、現在の時刻(00:00 (midnight) 01 January 1900 から秒数として計られた値)を、Network Byte Order の32-bit の整数として配信します。
s := Open( "deneb", "time" );
a := Array( 1 .. 4, 'datatype' = 'integer'[ 4 ] );
a[ 1 ];
参照
rtable, 用語集 - socket, Sockets パッケージの紹介, Sockets[Read], Sockets[WriteBinary], 持続中断のプロトコルと Sockets パッケージ
Download Help Document