×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    43

    Question Ad-hoc mode using UDP?

    I am thinking about using UDP over WLAN in Qt instead of using it in Symbian C++, this way I will have the chance to run the application in more devices. The question is the following:

    Is there any way to use only the WLAN connection? Is there any way to change the wireless mode to ad-hoc?

    Thank you in advance.

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    22

    Re: Ad-hoc mode using UDP?

    Quote Originally Posted by darksoul_e View Post
    I am thinking about using UDP over WLAN in Qt instead of using it in Symbian C++, this way I will have the chance to run the application in more devices. The question is the following:

    Is there any way to use only the WLAN connection? Is there any way to change the wireless mode to ad-hoc?

    Thank you in advance.
    use the sender (http://doc.trolltech.com/4.5/network...astsender.html) and receiver (http://doc.trolltech.com/4.5/network...treceiver.html) example code to learn how to handle UDP QT sockets.

    see this http://discussion.forum.nokia.com/fo...d.php?t=185941
    for the ad-hoc mode setup.

    Hope it helps.

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    43

    Re: Ad-hoc mode using UDP?

    Thank you emiusa77!

    So your advice is to use Qt for almost everything, but I should use the Symbian API for choosing the default IAP. This way, if I want to port my application to another platform I should change the part of the code that sets the Ad-hoc mode.

    Am I right?

    Thank you in advance!

    (I cannot find the documentation \nokia_plugin\openc\Openc_new_api_guide.doc, what I have to write before the first stroke?)

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    22

    Re: Ad-hoc mode using UDP?

    Quote Originally Posted by darksoul_e View Post
    Thank you emiusa77!

    So your advice is to use Qt for almost everything, but I should use the Symbian API for choosing the default IAP. This way, if I want to port my application to another platform I should change the part of the code that sets the Ad-hoc mode.

    Am I right?

    Thank you in advance!

    (I cannot find the documentation \nokia_plugin\openc\Openc_new_api_guide.doc, what I have to write before the first stroke?)
    I'm more comfortable with QT than Symbian that's why I'm operating at QT level. To set a default IAP you can do
    it by hard coding the IAP name in the setdefaultif api, which is a C api that you can embed both in QT and Symbian code. So if your app is just QT you can still use that api. The api is part of OpenC/C++ from version 1.6 but it is not yet documented in the help and just in that doc file. Below is a cut and paste from the doc:

    Code:
    - setdefaultif(const struct ifreq *)
    
    IMPORT_C int setdefaultif(const struct ifreq *);
    
    Description
    
    The setdefaultif function can be used to set (or remove) a default network interface (either IAP or SNAP) for the application. This default interface, if set, will be used by all the further socket related function calls (connect, send, write etc) and all the host resolver function calls (getaddrinfo, getnameinfo, gethostbyname, getaddrbyname etc).
    If there is a default interface set using setdefaultif and if there is a separate interface set on a socket using the ioctl system call, network operations on that socket will not use the default one, but the socket specific interface.
    To remove the default interace, pass NULL as the argument.
    To set an IAP name as the default interface, the 'ifr_name' member of the 'ifreq' structure must be filled with the IAP name to be set. Unicode IAP names can also be set by converting them to UTF8 format before passing them to this API. See the example below:
    
    
    #include <stdio.h>
    #include <string.h>
    #include <net/if.h>
    
    int main()
        {
        struct ifreq ifReq;
        int ret;
        
        /* Set the default interface using IAP name */
        strcpy( ifReq.ifr_name, "Example Interface Name" );
        ret = setdefaultif( &ifReq );
        if( ret == -1 )
            printf( "Setting default interface failed with errno = %d", errno );
        
        /* Perform network operations */
        /* ... */
        
        /* Remove the default interface */
        ret = setdefaultif( NULL );
        if( ret == -1 )
            printf( "Removing default interface failed with errno = %d", errno );
        
        return 0;
        }
    
    To set a SNAP id as the default interface, the 'ifr_name' member of the 'ifreq' structure must be an empty string. In this case, the 'snap_id' member of the 'ifr_ifru' union in the parameter should contain the SNAP id to be set. It is recommended to zero initialize the 'ifreq' structure in this case. See the example below.
    
    int main()
        {
        struct ifreq ifReq;
        int ret;
        unsigned int snapId = /* Get the SNAP id to be set from the application settings */
        
        /* Set the default interface using SNAP id */
        
        /* memset the ifreq to make sure that the interface name is an empty string */
        memset(&ifReq, 0, sizeof(struct ifreq));
        ifReq.ifr_ifru.snap_id = snapId;
        
        ret = setdefaultif( &ifReq );
        if( ret == -1 )
            printf( "Setting default interface failed with errno = %d",  (*__errno())  );
        
        /* Perform network operations */
        /* ... */
        
        /* Remove the default interface */
        ret = setdefaultif(  0  );
        if( ret == -1 )
            printf( "Removing default interface failed with errno = %d",  (*__errno())  );
        
        return 0;
        }
    
    The setdefaultif is not guaranteed to be thread safe.
    Parameters
    const struct ifreqifreq *
    
    
    Return value
    int	The setdefaultif returns 0 on success and -1 on failure. Specifically, if the interface is not found, -1 is returned and errno is set to ENOENT.

Similar Threads

  1. Connnecting two N95 in WLAN ad hoc mode
    By npradeep in forum Wired and Wireless interfaces (Closed)
    Replies: 4
    Last Post: 2010-04-27, 18:04
  2. How to assign static IP in ad hoc mode
    By iisaint in forum Symbian Networking & Messaging (Closed)
    Replies: 8
    Last Post: 2009-10-09, 18:42
  3. Fix problem on WLAN ad hoc between PC and Mobile
    By jusore in forum Mobile Web Server
    Replies: 0
    Last Post: 2008-06-30, 16:11
  4. Ad Hoc Mode Access Point connection
    By primal in forum Symbian Networking & Messaging (Closed)
    Replies: 13
    Last Post: 2008-02-11, 23:44
  5. Ad hoc VOIP application?
    By andersn in forum Wired and Wireless interfaces (Closed)
    Replies: 0
    Last Post: 2007-05-18, 23:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×