import java.io.*;
import javax.microedition.io.*;
import javax.bluetooth.*;

public class L2CAPServer {
    public static void main( String args[] ) {
        try {
            String url = "btl2cap://localhost:" + 
                "0000000000000000000000000000ABCD" + 
                ";name=JSR82_ExampleService";

            L2CAPConnectionNotifier service = 
                (L2CAPConnectionNotifier) Connector.open( url );
            L2CAPConnection con = 
                (L2CAPConnection) service.acceptAndOpen();

            String greeting = "JSR-82 L2CAP server says hello";
            con.send( greeting.getBytes() );

            byte buffer[] = new byte[80];
            int bytes_read = con.receive( buffer );
            String received = new String(buffer, 0, bytes_read);
            System.out.println("received: [" + received + "]");
            
            con.close();
        } catch ( IOException e ) {
            System.err.print(e.toString());
        }
    }
}

