Results 1 to 5 of 5

Thread: Problem with CBluetoothSocket::Accept() multi connection

  1. #1
    Join Date
    Feb 2010
    Posts
    188

    Problem with CBluetoothSocket::Accept() multi connection

    Hi all,
    I have written a code for listening a bluetooth connection, but the problem with the code is that it is capable of accepting only one connection. I mean it is listening to only one connection. I have tried to specify the number of connection but then also the result is same below is the code which I have used.

    // I have used this for attaching the security settings.
    btsockaddr.SetSecurity(secSettings);

    // This used for Binding bluetooth socket which is CBluetoothSocket)
    User::LeaveIfError(iListenSock->Bind(btsockaddr));

    // I have used this for listening the port
    iListenSock->Listen(KSizeOfListenQueue); //this is 5

    // I have used this for Opening the blank socket and then pass it to accept to be assigned a proper
    // And the socket upon completion of Accept()
    iSock = CBluetoothSocket::NewL(*this, iSocketServ);

    // It is used to Set accept incoming connections,
    //which will be handled by the BluetoothNotifier
    iListenSock->Accept(*iSock);

    According to the reference the call will extracts the first pending connection on the queue of sockets, the queue size before specified by using CBluetoothSocket::Listen(TUint). After the successful completion the blank socket is given the handle for the new socket and it can be used for transfer the data, and after the completer the accept socket is used for making the further connection. Which will be with the new blank sockets. I just want to know what to do now I want to pass the socket to another thread. Finally I want to know how to receive multiple connection using CBluetoothSocket::Accept() multi connection

  2. #2
    Join Date
    Oct 2008
    Posts
    951

    Re: Problem with CBluetoothSocket::Accept() multi connection

    I am also facing the similar problem, I this simple test MIDlet I am getting followed by about 20 POST’s and final GET to a CGI on the webserver. The weird thing is that after 10 or 11 requests goes through running on the Nokia 3650 I get an IOException with "status -33" which I have learned means timeout. Following getting the first IOException subsequent requirements also timeout. It is as if my net connection is unexpectedly dead. In addition, it consistently happens after about 10 messages.

    So my question is this: am I forgetting to clean up some reserve or something and causing the networking layer of the phone to stop? I make sure to close the HTTPConnection and all my streams when I am done with them...




    public class tTestForm extends Form implements CommandListener
    {
    private Command fConnectCommand;

    public tTestForm()
    {
    super("Test");
    setCommandListener(this);

    fConnectCommand = new Command("Connect", Command.SCREEN, 1);
    addCommand(fConnectCommand);
    }


    public void commandAction(Command command, Displayable displayable)
    {
    if (command == fConnectCommand)
    {
    mGet("http://www.something.com/mycgi.cgi?param=login");
    for (int i = 0; i < 20; i++)
    {
    mPost("http://www. something.com/mycgi.cgi", "mydata");
    }
    mGet("http://www. something.com/mycgi.cgi?param=logout");
    }


    public String mGet(String url)
    {
    try
    {
    HttpConnection connection = (HttpConnection)Connector.open(url,
    Connector.READ_WRITE);

    if (connection.getResponseCode() == HttpConnection.HTTP_OK)
    {
    StringBuffer response = new StringBuffer();

    DataInputStream dis = new DataInputStream(connection.openInputStream());

    int ch;
    while ((ch = dis.read()) != -1)
    {
    response.append((char)ch);
    }

    dis.close();
    connection.close();
    connection = null;

    return response.toString();
    }
    else
    {
    connection.close();
    connection = null;
    }
    }
    catch (IOException E)
    {
    append(E.getMessage());
    E.printStackTrace();
    }

    return null;
    }


    public String mPost(String url, String data)
    {
    try
    {
    HttpConnection connection = (HttpConnection)Connector.open(url,
    Connector.READ_WRITE);

    connection.setRequestMethod(HttpConnection.POST);

    DataOutputStream dos = connection.openDataOutputStream();
    byte[] requestBody = data.getBytes();

    for (int i = 0; i < requestBody.length; i++)
    {
    dos.writeByte(requestBody[i]);
    }

    dos.close();

    if (connection.getResponseCode() == HttpConnection.HTTP_OK)
    {
    StringBuffer response = new StringBuffer();

    DataInputStream dis = new DataInputStream(connection.openInputStream());


    int ch;
    while ((ch = dis.read()) != -1)
    {
    response.append((char)ch);
    }

    dis.close();
    dis = null;

    connection.close();
    connection = null;

    return response.toString();
    }
    else
    {
    connection.close();
    connection = null;
    }
    }
    catch (IOException E)
    {
    append(E.getMessage());
    E.printStackTrace();
    }

    return null;
    }
    }

  3. #3
    Join Date
    Dec 2008
    Posts
    950

    Re: Problem with CBluetoothSocket::Accept() multi connection

    Well I am trying to understand the symptoms as a series of request on the 3650, and after that "Status = -33" and then the following connection will not work.
    The thing about the more than 10 request is other than closing all streams, I am unable to think of what could be the exact problem.

  4. #4
    Join Date
    Oct 2008
    Posts
    780

    Re: Problem with CBluetoothSocket::Accept() multi connection

    This was a while ago and since then we have to tackle the number of network related problem. But after a lot of hard work we have solved the problem.
    The problem is because of the access point’s gateway on the 3650. The actual culprit was the default Access point. I do not what is the reason but it is causing the failure after 10 or the HTTP request. Access point on the phone with the use of Gateway Internet Protocol address 0.0.0.0 and then use it for connecting in place of the default access point we have not seen more than 10 request bug.
    Below is the Access point settings we have used.

    Connection name: you can use any name you want
    Data bearer: GPRS
    Access point name: Proxy
    User name: None
    Prompt password: No
    Password:
    Authentication: Normal
    Gateway IP address: 0.0.0.0

    I think this will solve your problem.

  5. #5
    Join Date
    Feb 2010
    Posts
    125

    Re: Problem with CBluetoothSocket::Accept() multi connection

    I have heard about the Gateway of 0.0.0.0 solution, but it is not working for us. I do not know the reason but the internet APN keeps on returning “ Bad request” and then using then using the WAP APN and after that changing the gateway to 0.0.0.0 disables any connectivity. Hence, I am stuck with this problem and have no idea what to do.

Similar Threads

  1. The remote device or resource won't accept the connection
    By snav in forum Technology & Internet
    Replies: 1
    Last Post: 22-10-2010, 12:51 AM
  2. Replies: 6
    Last Post: 14-08-2010, 03:23 AM
  3. Accept incoming connection using Socks Proxy
    By Susquehannock in forum Technology & Internet
    Replies: 6
    Last Post: 29-06-2010, 05:43 AM
  4. Multi Speakers/multi Sound Cards
    By PeterAGASSI in forum Hardware Peripherals
    Replies: 5
    Last Post: 12-11-2008, 11:40 AM
  5. Multi GPUs Problem
    By Orson in forum Monitor & Video Cards
    Replies: 4
    Last Post: 11-11-2008, 03:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,441,781.38085 seconds with 16 queries