Android developers 翻訳 - android.bluetooth その2

今日は BluetoothServerSocket, BluetoothSocket を訳してみました。

次は何を訳そうかな・・・リクエスト募集中。

Android搭載端末(MID)を探し中。smartq5より画面が大きくて、お手頃な。。

        • -

BluetoothServerSocket

Class Overview

A listening Bluetooth socket.
The interface for Bluetooth Sockets is similar to that of TCP sockets: Socket and ServerSocket. On the server side, use a BluetoothServerSocket to create a listening server socket. When a connection is accepted by the BluetoothServerSocket, it will return a new BluetoothSocket to manage the connection. On the client side, use a single BluetoothSocket to both intiate an outgoing connection and to manage the connection.
The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP).
●リスンする側のブルートゥースソケット。
ブルートゥースソケットのインターフェースはTCPソケットに類似しています。すなわちSocketとServerSocket。 サーバサイドでは、リスニングサーバソケットを生成する為にBluetoothServerSocketを使用して下さい。BluetoothServerSocketで接続がアクセプトされたら、BluetoothServerSocketは接続を管理する為に新しいBluetoothSocketをリターンします。クライアントサイドでは、接続を開始する為、接続を管理する為の両方に一つのBluetoothSocketを使用して下さい。
ブルートゥースソケットのタイプとして最も一般的なのはRFCOMMで、Android APIでサポートされるタイプです。RFCOMMは接続オリエンテッドブルートゥース上でのストリーミング送信です。またSerial Port Profile (SPP)としても知られています。

To create a listenting BluetoothServerSocket that's ready for incoming connections, use BluetoothAdapter.listenUsingRfcommWithServiceRecord(). Then call accept() to listen for incoming connection requests. This call will block until a connection is established, at which point, it will return a BluetoothSocket to manage the connection. Once the BluetoothSocket is acquired, it's a good idea to call close() on the BluetoothServerSocket when it's no longer needed for accepting connections. Closing the BluetoothServerSocket will not close the returned BluetoothSocket.
BluetoothServerSocket is thread safe. In particular, close() will always immediately abort ongoing operations and close the server socket.
Note: Requires the BLUETOOTH permission.
●インカミングな接続に準備が整ったリスニングBluetoothServerSocketを生成する為には、BluetoothAdapter.listenUsingRfcommWithServiceRecord()を使用して下さい。そして、インカミングの接続リクエストをリスンする為にはaccept()をコールして下さい。このコールは接続が確立されるまではブロックします。接続確立時には、接続管理の為にBluetoothSocketをリターンします。BluetoothSocketが取得できたら、BluetoothServerSocketのclose()をコールするのも良いです。接続をアクセプトする必要がありませんので。BluetoothServerSocketをクローズしてもリターンされたBluetoothSocketはクローズされません。
BluetoothServerSocketはスレッドセーフです。特に、close()は常に即座に動作中の処理を中止し、サーバーソケットをクローズします。
注意:BLUETOOTHパーミッションが必要です。

        • -

BluetoothSocket

Class Overview

A connected or connecting Bluetooth socket.
The interface for Bluetooth Sockets is similar to that of TCP sockets: Socket and ServerSocket. On the server side, use a BluetoothServerSocket to create a listening server socket. When a connection is accepted by the BluetoothServerSocket, it will return a new BluetoothSocket to manage the connection. On the client side, use a single BluetoothSocket to both intiate an outgoing connection and to manage the connection.
The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP).
●接続された、または接続しようとしている側のブルートゥースソケット。
ブルートゥースソケットのインターフェースはTCPソケットに類似しています。すなわちSocketとServerSocket。 サーバサイドでは、リスニングサーバソケットを生成する為にBluetoothServerSocketを使用して下さい。BluetoothServerSocketで接続がアクセプトされたら、BluetoothServerSocketは接続を管理する為に新しいBluetoothSocketをリターンします。クライアントサイドでは、接続を開始する為、接続を管理する為の両方に一つのBluetoothSocketを使用して下さい。
ブルートゥースソケットのタイプとして最も一般的なのはRFCOMMで、Android APIでサポートされるタイプです。RFCOMMは接続オリエンテッドで、ブルートゥース上でのストリーミング送信です。またSerial Port Profile (SPP)としても知られています。

To create a BluetoothSocket for connecting to a known device, use BluetoothDevice.createRfcommSocketToServiceRecord(). Then call connect() to attempt a connection to the remote device. This call will block until a connection is established or the connection fails.
To create a BluetoothSocket as a server (or "host"), see the BluetoothServerSocket documentation.
Once the socket is connected, whether initiated as a client or accepted as a server, open the IO streams by calling getInputStream() and getOutputStream() in order to retrieve InputStream and OutputStream objects, respectively, which are automatically connected to the socket.
BluetoothSocket is thread safe. In particular, close() will always immediately abort ongoing operations and close the socket.
Note: Requires the BLUETOOTH permission.
●既知デバイスへの接続用BluetoothSocketを生成する為には、BluetoothDevice.createRfcommSocketToServiceRecord()を使用して下さい。そして、リモートデバイスへの接続を試みるにはconnect()をコールして下さい。このコールは接続が確立されるまでまたは接続が失敗するまでブロックします。
サーバ(ホスト)としてBluetoothSocketを生成するには、BluetoothServerSocketを参照下さい。
クライアントが開始、またはサーバがアクセプトどちらの場合でもソケットが接続されたなら、InputStream,OutputStreamオブジェクトを取得する為にgetInputStream()とgetOutputStream()をコールしてIOストリームをそれぞれオープンして下さい。それらはソケットに自動的に接続されているものです。
BluetoothServerSocketはスレッドセーフです。特に、close()は常に即座に動作中の処理を中止し、サーバーソケットをクローズします。
注意:BLUETOOTHパーミッションが必要です。