File: client_connection

package info (click to toggle)
libnet-bluetooth-perl 0.40-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 164 kB
  • ctags: 15
  • sloc: perl: 131; makefile: 7
file content (22 lines) | stat: -rwxr-xr-x 856 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use Net::Bluetooth;

	#### Create a RFCOMM client

	#### Create a new socket object, this is basically calling
	#### the systems socket() call and setting some variable.
	#### The argument can be either "RFCOMM" or "L2CAP".
	my $obj = Net::Bluetooth->newsocket("RFCOMM");
	die "Socket could not be created!" unless(defined($obj));

	#### Connect to server. You can see how to obtain the port and 
	#### address in the service sample file.
	if($obj->connect($addr, $port) != 0) {
		die "connect error: $!";
	}
                                                                                                                   
	#### Create a Perl filehandle for reading and writing
	#### The filehandle should work with any Perl call that
	#### does not use the sockaddr struct.
	*SERVER = $obj->perlfh();
	$amount = read(SERVER, $buf, 256);
	close(SERVER);