I have an array filled with TBTSockAddr values which are inserted when i perform my discovery. My array is defined like this:
Later i wish to form a connection, but first i need to supply the Socket.Connect() function with a TBTSockAddr from the array.
So just to test the code, ... i do this:
I get the following error:
error C2664: '__thiscall TBTSockAddr::TBTSockAddr(const class TSockAddr &)' : cannot convert parameter 1 from 'class CArrayFixSeg<class TSockAddr>' to 'const class TSockAddr &'
Reason: cannot convert from 'class CArrayFixSeg<class TSockAddr>' to 'const class TSockAddr'
No constructor could take the source type, or constructor overload resolution was ambiguous
Any idea anyone?
If its of any help, here's how i insert values into my array:
Thanks, I do hope u have time for one more question..
I can now make connections , but have some issue about the ports, which makes my connections funny.
Lets say i have an advertising server, and a connecting client.
This is some code from the server, :
// Get a channel to listen on - same as the socket's port number
iListeningSocket.GetOpt(KRFCOMMGetAvailableServerChannel, KSolBtRFCOMM, channel)
1) Is the 'channel' the 'port'? or are they 2 different entities but with are being assigned the same value?
2) Does the port specified in the TSockAddr on the client have to be the same as the port number on the Server? Are they even related?
If they need to be the same i have no idea how to get the server port for the client to use. Examples usually use fixed ports for the client, e.g:
I'm using RHostResolver to automate discoveries, not RNotifier,,
I know that BTP2P has some way of getting the remote port by using
void CMessageServiceSearcher::FoundElementL(TInt aKey, CSdpAttrValue& aValue)
__ASSERT_ALWAYS(aKey == static_cast<TInt>(KRfcommChannel), Panic(EBTServiceSearcherProtocolRead));
iPort = aValue.Uint();
I'm not sure how it works anyway..
As far as i know, RHostResolver returns a TNameEntry object, rather than a responseparamspackage thing which comes with RNotifier. The TNameEntry apparently doesn't have the that the port that the remote device is using . I'm not sure how to get this port.
Most of the time my phone(if it is the server) is dynamically assinged the listening port = 4, using the GetOpt command. There was once it was 3. The emulator, if it becomes the server ,is always dynamically assigned the listening port 1.
I'm worried that if i give the client a fixed port to connect to (e.g: 4) the server, things may not workout all the time. I could copy paste the code from BTP2P and get the remote port (however it does it), but in my case i'm using RHostResolver.
So i have to set my stuff like this, using a fixed port for client to connect to:
Suppose that I've written a background server that uses RfComm. This does it the correct way, and is usually allocated channel 4.
Now someone tries to run your application on a phone that is already running my application. Are you going to tell them that they have to close my app, start your app, and then they can start my app again?
What if we both hardcoded our apps to be on channel 4?
Yeap i did see that problem.. so i came up with yet another idea.
Assume my server is now dynamically assigning the rfcomm channel/port with GetOpt. I can insert that port in my service description for the remote device to parse and connect to.
This way they'll always be connecting to the correct ports.
I've another small prob, lets say I have successfully connected my Client to the remote Server via sockets. This only allows one way transfer of data.
I'm planning to do some full duplexing here, so i want my client,after connecting, to tell the server to connect back to it, to the client's listening port(probably a separate active object). That is, i will then have 2 active objects running on the client (server will also have 2 then).
One for connecting and sending data,
One for listening and receiving conections.
**Tada!.. 2 way communication!
**Client already connected to Server. Server needs client port and BT device addr toconnect back..right?***
I can get the Client's listening port value to be sent to the Server to be parsed, but if i'm not wrong the server also needs the Client device address(TBTDevAddr). Example code for server's connecting socket:
iBTSockAddr.SetBTAddr(Where to get this value?); //clients device addr (TBTDevAddr)
iBTSockAddr.SetPort(ClientPort);//client can send this over to server...
How can i get the Client's local device address(TBTDevAddr) for the Server to connect to? (at this point the client has already connected itself to the server)