Hi all, I have a question I hope someone can help me with:
I'm doing some communication over a socket, and have need to send
and receive values of type double. I'm doing everything in terms
of single byte reads and writes to the socket, so what I need to do
is take the individual bytes I receive, that represent a double, and
actually turn them into a double. This I'm struggling to figure
out.
I can easily combine the bytes into a container of some sort
(like say a long) that has the same bit pattern as the double
I want. For example, I can get to the point of having a long
that looks like 0001 1110 1000 0000 for 7.5d. But I can't
seem to get that into a double. A simple cast doesn't appear
to work, and I'm not sure what else to try.
Any help or ideas is greatly appreciated.
Thanks,
Phillip Rhodes
--
North Carolina - First In Freedom
Free America - Vote Libertarian www.lp.org
Jul 23 '05
15 6732
Greg wrote:
[snip]
It's also reinventing the wheel. For sending data types and data structures over a network, by the far the easiest and most interoperable approach would be to use ASN.1 notation and a BER library (Basic Encoding Rules) to encode and decode the data on both ends of the connection. Not only do well-debugged, freely available implementations exist on every major platform, but the BER notation being self-describing is quite robust. It is the data encoding format used by dozens of standards and innumerable RFCs.
[snip]
Could you provide some links to Linux Open Source libs req'd to
do the job - libs to be linked to a C++ app.
Google hasn't helped much with this.
Thanks,
Larry
Greg wrote: It's also reinventing the wheel. For sending data types and data structures over a network, by the far the easiest and most interoperable approach would be to use ASN.1 notation and a BER library (Basic Encoding Rules) to encode and decode the data on both ends of the connection. Not only do well-debugged, freely available implementations exist on every major platform, but the BER notation being self-describing is quite robust. It is the data encoding format used by dozens of standards and innumerable RFCs.
Hmmm... I have to admit, I'm not very familiar with ASN.1. I'll look
into it, but I suspect it may be overkill for what I'm trying to do.
I'll definitely look it up and take a look though.
TTYL,
Phil
--
North Carolina - First In Freedom
Free America - Vote Libertarian www.lp.org
Greg schreef: It's also reinventing the wheel. For sending data types and data structures over a network, by the far the easiest and most interoperable approach would be to use ASN.1 notation and a BER library (Basic Encoding Rules)
Even easier than text? I mean, reading and writing "1.0" is very easy.
Best of all, if it doesn't work you can look at the raw bits and
understand them. Try that with ASN.1
There's a good reason most RFCs use text and not ASN.1
HTH,
Michiel Saltres
Text is a very fine thing. However, you might lose precision while
converting back and forth the decimal-based text format. li*****@gmail.c om wrote: http://lionet.info/asn1c is a free ASN.1 compiler.
Awesome, thanks for the link. I'm not 100% sure
I need ASN.1 for the problem I'm working on right now,
but it definitely looks like something I should get
familiar with. I'll definitely be downloading
and looking at this.
Thanks again,
Phillip
--
North Carolina - First In Freedom
Free America - Vote Libertarian www.lp.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Harris |
last post by:
My K&R 2nd ed has in the Reference Manual appendix, A7.4.8 sizeof yields
the number of BYTES required to store an object of the type of its operand.
What happens if C is running on a machine that addresses larger words only?
Shouldn't sizeof be defined to return the smallest number of 'storage
units' required to store an object of the type of its operand?
As a general point, is there a guide to what aspects of C would fail if run
on a...
|
by: Allan Rydberg |
last post by:
hi
i'm trying to shift a double, but i'm getting the
error message '>>' illegal, left operand double.
althought that the manpages say, '>>' and '<<' can
be applied for int's only, i was able to use the
shift operator on unsigned longs without any problems.
does anyone know how to do this properly?
|
by: abhi147 |
last post by:
Hi ,
I want to convert an array of bytes like :
{79,104,-37,-66,24,123,30,-26,-99,-8,80,-38,19,14,-127,-3}
into Unicode character with ISO-8859-1 standard.
Can anyone help me .. how should I go about doing it ?
Thanks
|
by: Nutkin |
last post by:
Hi i have to program a code to perform 1 of 5 functions at the users
request, I have got to the part where i have to program the equations
and i cant seem to get them to link together. Basicly when the used
enters his radians i was to link to a sin x function to calculate the
sin of the number also there will be a factorial function and a cos
function. but none of them are linking.
#include <iostream>
using namespace std;
|
by: Robert Seacord |
last post by:
The C standard doesn't say anything about what happens when you call
realloc with a size argument of 0. Both glibc and openbsd appear to
return a valid pointer to a zero-sized object.. e.g. the return of a
malloc(0).
Does anyone know of a runtime where realloc() free'ed the object and
then returned NULL? If so, it would make the following idiom for
realloc() exploitable. Here's the idiom, snagged from an openbsd man page:
if ((p2 =...
| |
by: Freddy Coal |
last post by:
Hi, I'm trying to read a binary file of 2411 Bytes, I would like load all
the file in a String.
I make this function for make that:
'--------------------------
Public Shared Function Read_bin(ByVal ruta As String)
Dim cadena As String = ""
Dim dato As Array
If File.Exists(ruta) = True Then
|
by: Tristan Miller |
last post by:
Greetings.
Is it possible using HTML and CSS to represent a combining diacritical mark
in a different style from the letter it modifies? For example, say I want
to render Å‘ (Latin small letter o with a double acute accent), but with
the o in black and the double acute accent in green. Are either of the
following valid?
1. <span style="color: black;">o</span><span style="color:
green;">̋</span>
|
by: H |
last post by:
Hi,
I have the following address fields in a table:
flat_number
house_name_or_number
street
village
postal_town
county
postcode
|
by: girays |
last post by:
I want to make a good design about combining information. Suppose you
have different data types, and each may have semantically same data. I
want to merge these different data types into a single data at run-
time. For example, sonar sensor has two internal data (bearing and
bearing_rate), and Radar has two as well (range, bearing.
struct sonar_data {
float bearing;
float bearing_rate;
};
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |