Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I just started a summer job at my university doing work in a lab, and I've been given a rather large, vague problem to tackle without much guidance so I was hoping someone could help point me in the right direction.
Essentially it's a 3-d world built in Qt using VTK (Visualization ToolKit) for use in therapy and rehab, and my task is to find a way to network two or more instances of the program so that users can share the same 3-d environment (essentially a networked video game).
The professor wants it to be secure, for latency to be as low as possible, and for the program to record data after a session is complete.
So far I was thinking (without much experience) of doing a client/server model built in Qt, but I'm not sure where to start.
Q1:
Should I use Boost.asio, or Qt library for networking?
Q2:
Are there any concepts I should be mindful of from the get-go for security, and network programming in general? (I've heard good things about Beej's Guide, and books by W. Richard Stevens)
Trying to answer your first question, it depends on which platforms are you targeting (Windows, Linux, OSX...). You could use native OS socket api (bsd sockets or winsock) but Qt provides very good abstractions for these so for the sake of simplicity I would stick with it. I'm unfamiliar with boost.asio but I'm pretty sure that Qt could provide you with all you need disregarding the platform you intent to target.
As for the second question, you have to carefully analyze what kind of information you want to transmit and what will characterize the exchange.
If you intend to make it like a video game where players interact in real time, you are bound to use UDP sockets (although some data can go missing, it allows for "real time" communication). Control messages can circulate through TCP as the impact of latency won't be so critical and you want them to be reliably sent, so consider having two sockets (TCP and UDP) if that's the case, and use them for their purposes.
Those resources that you link are quite informative but assuming you have knowledge of TCP and UDP and their features, I would suggest you to brush up your multithreading skills. Qt offers you good infrastructure for this, but topics like Asynchronous I/O (how to implement selectable sockets) may help you to create a better design that will remove a lot of overhead from additional threads (specially for reading).
These are my 2 cents.
Good luck for your project, I'm sure it will be a good chance for you to learn and put some theory into practice.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I got a desktop application and it's getting bigger and bigger. And i wonder if i can make something like microservices with desktop application? I want to application for now stays desktop. Application it's written in C++.
I can exclude some of the modules with some preparations.
But is it possible and if anybody have idea how to start with this?
A microservice-like architecture for the desktop is feasible. In fact, many OSes use services, which are often called daemons. For instance, the X Window system uses a client/server architecture. More recently, IDEs can now use the Language Server Protocol to communicate with one or more language servers that provide syntax highlighting, code completion, compilation feedback, etc.
There are a few things to consider:
What communication protocols are already available on the target system? On many systems, you can use a D-Bus (https://en.wikipedia.org/wiki/D-Bus)
What performance do you need? If performance is highly critical, you will need to use a highly optimized protocol for communicating between services, and startup times will need to be small. For good performance, something similar to the Language Server Protocol is probably good enough and will be easier to write, maintain and debug.
Can you handle the added complexity of splitting processes up? In a monolith, the whole thing is either up or down. With microservices, parts of the system that are running can attempt to call parts that are not. This situation must be handled.
What are the seams in your applications? Where can you split it up easily? Take a look at Domain Driven Design. Identify potential independent modules, and refactor to confirm. If the refactoring makes sense then split the module into its own process.
Desktop application and microservices are mutually exclusive because Desktop means one machine and microservices implies multiple machines (physical or virtual) that communicate through network using a technology agnostic protocol.
What you can do is to use modularization. This is an alternative to microservices that can work in some scenarios like yours.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I can't seem to find the answer I'm looking for, or I might miss understand this. Either way I am confused.
When I try to find out, there is always videos about C++ console programming, which annoys me because I wanna move away from console stuff by now. I know how to create a simple window, but not how to display real graphics on it. I have heard of stuff like OpenGL and DirectX, but it makes me wonder, what do those libraries have in their source whcih draws actual shapes and other things on the program? What C++ functions do they use in their code?
Well, you could make your own graphics library. In that case I suggest you grab a good math book, and get ready to do some rather serious maths. You'd also have to get going and start right now to learn about Windows graphics drivers and Windows Kernel development, or about the X11 API and Linux Kernel programming, or all of those. The documentation is available on the Net.
What OpenGL and other graphics libraries do is provide a relatively simple API so you don't have to reinvent the wheel, and make your own library which would take years before having anything close to what they provide.
Don't get me wrong, even with these nice API's, there is much room for doing 'magic'. Computer graphics are an art in and of themselves. Mastering some of the techniques offered by the libraries require a good knowledge of the maths involved, and of the possibilities offered by the hardware as well.
But, like everything, it can be learnt. If you are interested in doing graphics on a computer, you should start by finding a good source on the subject, there are many online. And start playing with the APIs. OpenGL is a good place to start, but there are also open source libraries that build on that, since drawing polygons ans stuff involves many other aspects of computing. Ogre3d comes to mind, but there are also others.
Briefly, what graphics APIs have in their source is interaction with the graphics hardware, and telling it to write pixel values in memory. Ultimately this is usually done in an indirect way, such as setting up a scene graph, and and graphics APIs provide an interface to work with low level hardware systems.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I recently asked the question if I could limit bandwidth via a C# WinForms applications much like NetLimiter and NetBalancer. I was told that there's two ways to do this. Either via proper QoS or writing something along the lines of an "NDIS Network Filter Driver". Using QoS isn't the way I want to take. So I've looked up some of the stuff required to write drivers and found some interesting points. Points such as a good understanding of C/C++, because the executed code being very prone to BSODs since it could be run in something called "Kernel mode". I also found a GitHub "dump" which looks interesting and tempts me to investigate and look around in.
As you can see I'm no where near advanced enough to delve into this on a professional level. Ignoring that, what would be a good start to start my adventures into writing drivers to monitor - and further down the line manipulate the network to introduce throttling.
Any help, guides or information that might be of help is always appreciated.
PS: I am unsure as to whether this is (as afore mentioned in a comment to my previous question) too broad a question to be answered on Stack Overflow. If so, where would I go to ask this?
Indeed, this would be too broad. Driver writing is a complicated thing which requires a good understanding of how a computer and the OS works. Also, C# (and .NET itself) indeed isn't available in Kernel Mode, so C/C++ is the preferred way. Although theoretically any unmanaged language (like Pascal) could do, I haven't heard of anyone writing drivers in them. Microsoft's own developer resources are also written with C/C++ in mind.
Which brings us to the question of why you want to do it.
If you need it for work and there's a deadline - forget it. Get someone else who already knows this stuff. Or there might be a library out there that fills the need. Any of these options will be cheaper than your time spent learning all this stuff.
If it's for your own curiosity however - go for it! I'd advise by starting to learn C first. Not C++, that's more complicated and for drivers it will be easier with C anyway. But you can pick up C++ later too, it's good stuff. C++ is mostly compatible with C, so you can start with C and then continue with C++.
In parallel, get a good book about OS design. Not because you want to design an OS, but to understand the basic concepts that it is built upon. You should get a good understanding of things such as Kernel Mode/User Mode, virtual memory, interrupts, process scheduling, etc.
Learning a bit of assembly might be useful too (albeit not required).
Finally, when you feel like you've got a good grasp of the above, head over to MSDN and start reading about driver development. There will be long articles and example programs to get you started. Tweak them and play around in a virtual machine until you get what you need.
And also... read this.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So my question is, would it be possible to write a protocol which does the same as the Internet Protocol, and if so, how do I get started? And don't say, "isn't the Internet Protocol good enough?", yes it is, it is just to see if it is possible:P
I would like to know a bit more about how,
just for learning how protocols are done. I have some experience in programming, but not anything like networking protocols.
The short answer is yes -- it has been done, and could be done again.
Examples of what have been done include DECnet, NetBIOS, Appletalk, and ATM. Although I'm not sure it was ever fully implemented as intended (though DECNet came pretty close), the standard OSI 7-layer model for networking was originally intended as a model of actual implementation (i.e., the intent was that people would implement those layers, and you'd be able to build a fully network stack by plugging together the implementation of your choice of each layer).
Of course, what most of us think of as IP today is really IPv4 -- as you can probably guess from the version number, it had predecessors (and a successor, IPv6).
Edit: as to how you do it: pretty much like anything else. I'd start by writing up something about your motivation -- what you want to accomplish, what sorts of operations it should support, etc. Then start working on the simplest design you can figure out that can possibly do what you want. Then, as you use it and encounter problems, figure out whether they stem from poor implementation, or shortcomings in the design itself. Modify one or both as needed, trying to keep its evolution as coherent and understandable as possible.
In short: Yes, it would be possible. On a higher level (i.e. OSI layer 7) it is done daily. If you want to implement the next IP, all you need are:
Special hardware (for the actual physical implementation, assuming that your protocol greatly differs from IP)
Device drivers for your favourite operating system that support your protocol
Maybe a high-level API to facilitate implementation
Edit: Saw that two others beat me to it ;)
would it be possible to write a protocol which does the same as the
Internet Protocol?
Yes it is possible to write your own IP stack, but it is extremely difficult to actually go ahead and do it (and actually do it right) unless you are an expert level both in programming and in networking
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 months ago.
Improve this question
Currently I'm working on a C/C++ cross-platform client/server software. I'm very experienced developer when it comes to low level socket development.
The problem with Berkley sockets/Winsock, is that you always have to make some kind of parser to get things right on the receiver side. I mean, you have to interpret data, and concatenate packets in order to transmit correctly. (packets often get sliced)
Have in mind that the communication is going to be bidirectional. Is pure socket the best way to transmit data nowadays? Would you recommend SOAP, Webservices or another kind of encapsulation to this application?
I can highly recommend Google Protocol Buffers.
These days many people use Web Services and SOAP. There are C++ packages available for this purpose. These will use sockets for you and handle all the data wrangling. If you are on Unix/Linux, give or take System V.4 network handles, your data will eventually travel over sockets.
On Windows there are other choices if you only want to talk to other Windows boxes.
You could also look into CORBA, but it's not the common practice.
In any data transfer, there is going to be a need to serialize and deserialize the objects.
The first question you want to ask is whether you want a binary or text format for the transfer. Binary data formats have the distinct advantage that they are totally easy to parse (provided they are simple POD structures - you can just cast them into a struct).
Text based transfers should be easier to debug since you can just read the text. You are still going to have to parse them.
SOAP based web services are simple XML based packets sent normally over HTTP. Something will have to parse the HTTP and the XML. The ease of use is not intrinsic but rather dependent of the tools at your disposal. If you have good tools, the by all means, but the same applies to any form of data exchange.
You can take a look at the Boost Serialization Library. It is a fairly complex library and does require you to write code indicating what members need to be serialized. IT does have good support for both text (including xml) and binary serialization. It is also cross platform.
I have used ZMQ with grate success. I highly recommend it as it is a middle-level library witch takes care the socket related overhead. It also supports binary packets/messages.