Solved

sockets, multicast and bluetooth

Posted on 2012-04-04
17
396 Views
Last Modified: 2012-08-15
Hi Experts,

Is it feasible and a good idea to create a TCP Server that would allow incoming sockets to be treated as observers of notifications, where these connections happen over bluetooth and/or over tcp/ip?  I would somehow have to create sockets that don't distinguish how the connection was made- is this how it's done?  Or does accepting both types of connections require 2 servers within the same application?

Thanks!
Mike
0
Comment
Question by:thready
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
17 Comments
 
LVL 22

Expert Comment

by:ambience
ID: 37806941
As far as I know there would be a need to abstract different addressing types, which BTW is also a case when you want IPv6. Luckily, on Windows, the same Winsock API is used for Bluetooth communication though with different addressing structures. See this http://msdn.microsoft.com/en-us/library/windows/desktop/aa362901%28v=vs.85%29.aspx.

I haven't done any bluetooth programming with sockets therefore I'm not sure whether you need to have two server sockets bound to different addresses each listening for incoming connections - but I am 99% thats the way it would be.

>> Is it feasible and a good idea to create a TCP Server that would allow incoming sockets to be treated as observers of notifications, where these connections happen over bluetooth and/or over tcp/ip?

Not sure I fully understood that.

Perhaps it would be better to have a say Proxy class that observes notifictaions and manages bidirectional communication. The proxy gets created for every incoming connection and owns the connection. There would be a list of proxies at any time and when a connection drops the proxy gets deleted. A proxy is also logical abstraction on a raw connection because you would most definitely want to add logging there, no? Sockets with logging becomes a bit esoteric IMHO.
0
 
LVL 22

Expert Comment

by:ambience
ID: 37806958
SubscriberProxy if you are subscribing from a remote system.
0
 
LVL 1

Author Comment

by:thready
ID: 37808366
What would the SubscriberProxy entail?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 22

Accepted Solution

by:
ambience earned 500 total points
ID: 37810385
I'm thinking again .. see my  thoughts attached
Untitled.png
0
 
LVL 1

Author Comment

by:thready
ID: 37813296
Awesome!  Just got this.  Looking over it all.  Wow thanks man!  :)
0
 
LVL 1

Author Comment

by:thready
ID: 37813312
Yet another one for you to see if interested  :)
http://www.experts-exchange.com/Programming/Languages/CPP/Q_27664404.html
0
 
LVL 1

Author Comment

by:thready
ID: 37813375
Which program did you use for the UML?
0
 
LVL 22

Expert Comment

by:ambience
ID: 37815516
I had a trial version of Visual Studio 2010 running - used the architectural project and grabbed screen
0
 
LVL 1

Author Comment

by:thready
ID: 37825991
I've been looking and looking again at your architecture.  I'm new to UML and I just don't get it.  Would you mind saying a few words about the flow of objects through this scheme?
0
 
LVL 22

Assisted Solution

by:ambience
ambience earned 500 total points
ID: 37827148
Let me try :)

NotificationService is the main object, this is the object that you'd use to raise notifications or get notifications from.

Internally it has a NotificationCenter which is kind of a registry of Observers (almost similar to POCO NotifcationCenter and certainly you can use it here). The NS uses the NC to manage local notifications etc.

The other main object is RemotingService, whose job is to manage a list of networked publishers/subscribers. So whenever a notification is raised the NS hands over to the RS. Also, when RS receives a notification it can

- either pass it to NC so that local entities are notified (RS can keep a reference of NC for that)
- pass upwards to NS and then NS can use NC (upto you how you design)

RS also has EndpontListerner whose job is to listen for connections and pass RS an Endpoint

The SubsriberProxy is the object that own an endpoint and RS creates a proxy and passes it the EP. SP does the job of serializing and deserializing notification objects into byte arrays. RS pass SP the notif and SP does the serialization. You can modify the design here and if the need is to send the same notif to every SP then the serialization can be done by the RS and pass same bytes array to all SP.

The last two entities comprise the serialization framework. Serializer is the abstract class (interface). A binary serializer would convert notif into your own binary format. You can later have say a GoogleProcotolBuffersSerializer that uses ProtBuffers for cross platform serialization or even XmlSerializer. Basically, a serializer is pluggable.

I hope that helps .. let me know if you have questions ...
0
 
LVL 22

Expert Comment

by:ambience
ID: 37827155
Correction: RS has a set of Listeners not just one. So each listerner can be listening on a different port/protocol/family
0
 
LVL 1

Author Closing Comment

by:thready
ID: 37828228
I see!  I think my SubscriberProxy could be the same object as my abstract base class for Notification objects.  Correct?  Thanks a lot for your help!  :)
0
 
LVL 22

Expert Comment

by:ambience
ID: 37828490
>>  I think my SubscriberProxy could be the same object as my abstract base class for Notification objects.

Why do you say that? In the diagram i didnt inherit Notification from anything but you are free to create a hierarchy if you want like

Notification
- UpdateNotification
- RefreshNotification

A Notification is just a notification. It can have a Notification code like UPDATE and it can have extra attributes or a list of key value pairs like an Hashtable. You can call it an Event or a Message if you prefer. If there is going to be a Request/Response sort of scenario then perhaps its better to call it Message (RequestMessage, ResponseMessage).

A Proxy on the other hand is an object that sends and receives Notifications. It can have a method say

void notify(const Notification& n) {
}
0
 
LVL 1

Author Comment

by:thready
ID: 38293436
Would you recommend NotificationService be a Singleton?
0
 
LVL 22

Expert Comment

by:ambience
ID: 38295611
its more of a preferences decision. It can be a singleton and thereby no need to keep the reference saved inside the children.

Its also possible to have a Kernel/Application/Services object and have it maintain the lifetime of services as well as provide means to locate, register and unregister. That object can itself be a singleton or even statically linked.
0
 
LVL 1

Author Comment

by:thready
ID: 38296225
Ah- singleton's are usually loaded dynamically?  (not statically linked?)

When you say register/unregister- you mean for events?
0
 
LVL 22

Expert Comment

by:ambience
ID: 38296460
no not saying anything about singleton's life-cycle. I was referring to just a global variable say

NotificationService gNotifService;

Register/UnRegiser were meant for the Service manager. E.g.

Kernel::registerService(string moniker, ServiceBase* service)
template<class T>
T findService(string moniker);

-----

In a distributed or pluggable architecture different modules can start and proffer services that may be used by other parts.  Just for idea:

NotificationService* ns = gKernel.findService<NotificationService>("notifications");
LogService* log = gKernel.findService<LogService>("log");
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advertise subnet not directly attached 6 56
Autosar OS Multicore Share Resources confusion ? 2 104
Routing protocols 5 36
print bytes of an integer 6 22
The article explains the protocols and technology which is involved when two computers on different TCP/IP networks communicate with each other. In the diagram, a router is used to segregate two networks. The networks are 192.168.1.0/24 and 192…
Please see preceding article here: http://www.experts-exchange.com/Networking/Operating_Systems/A_11209-Root-Bridge-Election.html Figure 1 After Root Bridge has been elected, then what?..... Let's start by defining a Root Port in la…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question