cap5lut
Named Pipe IPC: Protocols & Status Codes
the number of different high level data types doesnt matter, their serialization boils down to the primitives you want to support.
at the transport layer you are just sending bytes over, maybe with some sequence and fragment number to support something like UDP where packets could arrive out of order, or simply dont arrive.
the "hard" part here is only to discern which bytes belong to which message
once thats done and dusted it goes to how to do the serialization, no matter if thats reflection based or source generated or manually writing it, which itself isnt that problematic either, and can also be abstracted away.
ones all that is fixed u just need the application layer protocol, where the hard part is designing it.
basically here the different types come into play, for requests, for responses.
u want some generic status codes + optional data to process messages, pretty much like HTTP status codes.
62 replies
Named Pipe IPC: Protocols & Status Codes
i would abstract the transport layer and data (de)serialization away, so that u can first use simple stuff, like tcp and json and then make it configurable for faster alternatives like messagepack and named pipes/shared memory
62 replies
Named Pipe IPC: Protocols & Status Codes
u basically have this:
1) transport (fixed via named pipes i guess)
2) serialization (a bit of a struggle but u do it somehow)
3) application layer protocol
4) business logic
3 seems to be what u are stuck at, right?
62 replies
Help me with C++ / C#
@Siegthis sounds a lot like u want to write some unit or integration tests.
the question is what u really want to test.
use the .NET test frameworks to test the C# side.
use whatever c++ provides to test their side.
testing the interoperability will become quite a big task
17 replies
Help me with C++ / C#
basically for what you are looking for u are most likely need to host the runtime inside ur native code, unless u want to restrict urself to NAOT compiled libraries/programs, which itself is explained there:
https://learn.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting
and thats just a starter; you will need to read the whole (or at least most of the) "Native interoperablity" section
17 replies
Help me with C++ / C#
secondary u have to take into account, that C# (or .NET) uses garbage collection instead of explicitly freeing memory.
and at that a compacting one, thus on the C# side, the addresses of references could change and make them invalid, if they were created on the C# side.
17 replies
Exception Handling in C#
(as a side note, there is actually a third kind of exception: the uncatchable, these u will not see unless u do something unsafe that is close to the system, its the kind of problems where the process itself can not recover from)
85 replies
Exception Handling in C#
there are in the end 2 kinds of exceptions,
one that indicate bugs (like
ArgumentException
, NullReferenceException
) which u usually do not catch (or only catch them to log what went wrong)
the other kind is failure that is outside of ur control (eg the internet connection died because ur wifi sucks, or the human ripped out the usb stick while u write to that file)85 replies
Exception Handling in C#
when to throw exceptions is quite use case dependent.
ur math example: this is a bit more complex because the existence of
NaN
, its a value to indicate that an operation wasnt possible, without throwing.
thats because often u have quite complex computations going on there and then check at certain points if its NaN
to see if there is a failure (u dont want a try catch block for every division, do ya?)
for the age of a person: as with each other, this type should maintain a stable state, because a negative age isnt possible, its the callers fault to provide the wrong values and it should throw an exception (an ArgumentOutOfRangeException
in this case)85 replies
Exception Handling in C#
basically u want the state of ur class/type to be valid all the time,
lets assume the
DoSomethingThatMightThrow()
method modifies ur internal state.
due to the exception that state would become invalid the next time it is used, but catch the exception, fix the internal state to make it valid again, but still provide the caller with the exception of what went wrong85 replies