bluetooth.BluetoothSocket

Module bluetooth :: Class BluetoothSocket |
[show private | hide private]
[frames | no frames]

## Class BluetoothSocket

BluetoothSocket

availability: GNU/Linux, Windows XP

Method Summary
| ``__init__`(self, proto, _sock)` Create a new Bluetooth socket that uses the specified transport protocol.
| ``accept`(self)` accept() -> (BluetoothSocket, addrport)
| ``bind`(self, addrport)` bind(addrport) availability: GNU/Linux, Windows XP Bind the socket to a local adapter and port.
| ``close`(self)` close()
| ``connect`(self, addrport)` connect(addrport)
| ``dup`(self)` dup() -> socket object
| ``fileno`(self)` fileno() -> integer
| ``getpeername`(self)` getpeername() -> address info
| ``getsockname`(self)` getsockname() -> address info
| ``getsockopt`(self, level, option, buffersize)` getsockopt(level, option[, buffersize]) -> value
| ``gettimouet`(self, timeout)` gettimeout() -> timeout
| ``listen`(self, backlog)` listen(backlog)
| ``makefile`(self)` makefile([mode[, buffersize]]) -> file object
| ``recv`(self, buffersize, flags)` recv(buffersize[, flags]) -> data
| ``send`(self, data, flags)` send(data[, flags]) -> count
| ``sendall`(self, data, flags)` sendall(data[, flags])
| ``setblocking`(self, blocking)` setblocking(flag)
| ``setsockopt`(self, level, option, value)` setsockopt(level, option, value)
| ``settimeout`(self, timeout)` settimeout(timeout)
| ``shutdown`(self, flag)` shutdown(flag)

Method Details

### __init__(self, proto=0, _sock=None) (Constructor) Create a new Bluetooth socket that uses the specified transport protocol. proto can be one of RFCOMM, L2CAP, HCI, or SCO HCI, L2CAP, and SCO sockets are only available in GNU/Linux

### accept(self) accept() -> (BluetoothSocket, addrport) availability: GNU/Linux, Windows XP Wait for an incoming connection. Return a new socket representing the connection, and the address/port of the client. For L2CAP sockets, addport is a (host, psm) tuple. For RFCOMM sockets, addport is a (host, channel) tuple. For SCO sockets, addrport is just a Bluetooth address.

### bind(self, addrport)
    bind(addrport)

    availability: GNU/Linux, Windows XP

    Bind the socket to a local adapter and port.  addrport must always be a tuple.
      HCI sockets:    ( device number, )
                      device number should be 0, 1, 2, etc.
      L2CAP sockets:  ( host, psm )
                      host should be an address e.g. "01:23:45:67:89:ab"
                      psm should be an unsigned integer
      RFCOMM sockets: ( host, channel )
      SCO sockets:    ( host )

### close(self) close() availability: GNU/Linux, Windows XP Close the socket. It cannot be used after this call.

### connect(self, addrport) connect(addrport) availability: GNU/Linux, Windows XP Connect the socket to a remote device. For L2CAP sockets, addrport is a (host,psm) tuple. For RFCOMM sockets, addrport is a (host,channel) tuple. For SCO sockets, addrport is just the host.

### dup(self) dup() -> socket object availability: GNU/Linux Return a new socket object connected to the same system resource.

### fileno(self) fileno() -> integer availability: GNU/Linux, Windows XP Return the integer file descriptor of the socket.

### getpeername(self) getpeername() -> address info availability: GNU/Linux Return the address of the remote endpoint. For HCI sockets, the address is a device number (0, 1, 2, etc). For L2CAP sockets, the address is a (host,psm) tuple. For RFCOMM sockets, the address is a (host,channel) tuple. For SCO sockets, the address is just the host.

### getsockname(self) getsockname() -> address info availability: GNU/Linux, Windows XP Return the address of the local endpoint.

### getsockopt(self, level, option, buffersize) getsockopt(level, option[, buffersize]) -> value availability: GNU/Linux Get a socket option. See the Unix manual for level and option. If a nonzero buffersize argument is given, the return value is a string of that length; otherwise it is an integer.

### gettimouet(self, timeout) gettimeout() -> timeout availability: GNU/Linux Returns the timeout in floating seconds associated with socket operations. A timeout of None indicates that timeouts on socket operations are disabled.

### listen(self, backlog) listen(backlog) availability: GNU/Linux, Windows XP Enable a server to accept connections. The backlog argument must be at least 1; it specifies the number of unaccepted connection that the system will allow before refusing new connections.

### makefile(self) makefile([mode[, buffersize]]) -> file object availability: GNU/Linux Return a regular file object corresponding to the socket. The mode and buffersize arguments are as for the built-in open() function.

### recv(self, buffersize, flags=None) recv(buffersize[, flags]) -> data availability: GNU/Linux, Windows XP Receive up to buffersize bytes from the socket. For the optional flags argument, see the Unix manual. When no data is available, block until at least one byte is available or until the remote end is closed. When the remote end is closed and all data is read, return the empty string.

### send(self, data, flags=None) send(data[, flags]) -> count availability: GNU/Linux, Windows XP Send a data string to the socket. For the optional flags argument, see the Unix manual. Return the number of bytes sent; this may be less than len(data) if the network is busy.

### sendall(self, data, flags=None) sendall(data[, flags]) availability: GNU/Linux Send a data string to the socket. For the optional flags argument, see the Unix manual. This calls send() repeatedly until all data is sent. If an error occurs, it's impossible to tell how much data has been sent.

### setblocking(self, blocking) setblocking(flag) availability: GNU/Linux Set the socket to blocking (flag is true) or non-blocking (false). setblocking(True) is equivalent to settimeout(None); setblocking(False) is equivalent to settimeout(0.0).

### setsockopt(self, level, option, value) setsockopt(level, option, value) availability: GNU/Linux Set a socket option. See the Unix manual for level and option. The value argument can either be an integer or a string.

### settimeout(self, timeout) settimeout(timeout) availability: GNU/Linux Set a timeout on socket operations. 'timeout' can be a float, giving in seconds, or None. Setting a timeout of None disables the timeout feature and is equivalent to setblocking(1). Setting a timeout of zero is the same as setblocking(0).

### shutdown(self, flag) shutdown(flag) availability: GNU/Linux Shut down the reading side of the socket (flag == 0), the writing side of the socket (flag == 1), or both ends (flag == 2).

Generated by Epydoc 2.1 on Tue May 9 02:23:40 2006 | http://epydoc.sf.net