473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

A 64-bit binary returning a value to a 32-bit binary?

I have a program that needs to be compiled as 64bit. I have another
program that needs to be compiled as 32bit and will call that 64-bit
binary. Is there a way for the 64-bit binary to return a string to
the 32-bit? If so, how?

The only way I could think of is to have the 32-bit binary call the 64-
bit binary, then it writes to a text file and finally have the 32-bit
binary read it off.

Is there a better way to do this?

Mar 29 '07 #1
12 1846
sp*************@yahoo.ca wrote:
I have a program that needs to be compiled as 64bit. I have another
program that needs to be compiled as 32bit and will call that 64-bit
binary. Is there a way for the 64-bit binary to return a string to
the 32-bit? If so, how?

The only way I could think of is to have the 32-bit binary call the 64-
bit binary, then it writes to a text file and finally have the 32-bit
binary read it off.

Is there a better way to do this?
Does the 32 bit binary support long long? If not you may have to do as
you wrote, or use some non-portable means such as popen(), or invoke the
64 bit via a socket and read back the string from its standard output.
But of course all of that stuff is off-topic :-).

--
Regards,
Stan Milam
================================================== ===========
Charter Member of The Society for Mediocre Guitar Playing on
Expensive Instruments, Ltd.
================================================== ===========
Mar 29 '07 #2
On Mar 28, 11:18 pm, Stan Milam <stmi...@swbell.netwrote:
spammenotplu...@yahoo.ca wrote:
I have a program that needs to be compiled as 64bit. I have another
program that needs to be compiled as 32bit and will call that 64-bit
binary. Is there a way for the 64-bit binary to return a string to
the 32-bit? If so, how?
The only way I could think of is to have the 32-bit binary call the 64-
bit binary, then it writes to a text file and finally have the 32-bit
binary read it off.
Is there a better way to do this?

Does the 32 bit binary support long long? If not you may have to do as
you wrote, or use some non-portable means such as popen(), or invoke the
64 bit via a socket and read back the string from its standard output.
But of course all of that stuff is off-topic :-).

--
Regards,
Stan Milam
================================================== ===========
Charter Member of The Society for Mediocre Guitar Playing on
Expensive Instruments, Ltd.
================================================== ===========


Hi Stan,

I'm not good in C. What if it supports long long? What would be the
more efficient way of doing it? What sort of functions would I use
for the second method you suggested with invoking a socket?

Thanks! :)

Mar 29 '07 #3
On 29 Mrz., 04:58, spammenotplu...@yahoo.ca wrote:
On Mar 28, 11:18 pm, Stan Milam <stmi...@swbell.netwrote:
spammenotplu...@yahoo.ca wrote:
I have a program that needs to be compiled as 64bit. I have another
program that needs to be compiled as 32bit and will call that 64-bit
binary. Is there a way for the 64-bit binary to return a string to
the 32-bit? If so, how?
The only way I could think of is to have the 32-bit binary call the 64-
bit binary, then it writes to a text file and finally have the 32-bit
binary read it off.
Is there a better way to do this?
Does the 32 bit binary support long long? If not you may have to do as
you wrote, or use some non-portable means such as popen(), or invoke the
64 bit via a socket and read back the string from its standard output.
But of course all of that stuff is off-topic :-).
--
Regards,
Stan Milam
================================================== ===========
Charter Member of The Society for Mediocre Guitar Playing on
Expensive Instruments, Ltd.
================================================== ===========

Hi Stan,

I'm not good in C. What if it supports long long? What would be the
more efficient way of doing it? What sort of functions would I use
for the second method you suggested with invoking a socket?

Thanks! :)
Google for IPC, sockets are IMHO the best. Open a socket with port 0
and
pass the given port number to the callee. But you need to learn about
IPC
first to understand the sentence above.

Mar 29 '07 #4
llothar wrote:
On 29 Mrz., 04:58, spammenotplu...@yahoo.ca wrote:
>On Mar 28, 11:18 pm, Stan Milam <stmi...@swbell.netwrote:
>>spammenotplu...@yahoo.ca wrote:
I have a program that needs to be compiled as 64bit. I have another
program that needs to be compiled as 32bit and will call that 64-bit
binary. Is there a way for the 64-bit binary to return a string to
the 32-bit? If so, how?
The only way I could think of is to have the 32-bit binary call the 64-
bit binary, then it writes to a text file and finally have the 32-bit
binary read it off.
Is there a better way to do this?
Does the 32 bit binary support long long? If not you may have to do as
you wrote, or use some non-portable means such as popen(), or invoke the
64 bit via a socket and read back the string from its standard output.
But of course all of that stuff is off-topic :-).
--
Regards,
Stan Milam
================================================== ===========
Charter Member of The Society for Mediocre Guitar Playing on
Expensive Instruments, Ltd.
================================================== ===========
Hi Stan,

I'm not good in C. What if it supports long long? What would be the
more efficient way of doing it? What sort of functions would I use
for the second method you suggested with invoking a socket?

Thanks! :)

Google for IPC, sockets are IMHO the best. Open a socket with port 0
and
pass the given port number to the callee. But you need to learn about
IPC
first to understand the sentence above.
Having figured out all this stuff for your current platform, do you
expect the next person who maintains your application to spend the time
to come to the right conclusion? What if she is forced to come to the
conclusion mentioned above (not good in C....)?
Mar 30 '07 #5
Thanks for all the replies. I've opted to use p2open which will allow
the 32bit executable to write to stdout to 64bit's stdin. The 64bit
executable will then write to stdout and the 32bit will read it.

I want to make a small tweak though. I would like the 32bit to keep
the pipe open and the 64bit will constantly check to see if there's
anything new written to its stdin. Prior to attempting to modify
this, I was using fprintf and fgets in both programs to write and read
from stdout/stdin. My attempt to do the tweak was to put the entire
64bit program inside a "while (fgets(input, sizeof(input), stdin) !=
NULL)" loop. It doesn't work though. I don't think it is reading the
value. Before the while loop i opened a log file and inside the loop,
I would write the input to the log file. The log file is created but
there's nothing in the log.

Is there anything wrong with my approach? Thanks.

Apr 2 '07 #6
sp*************@yahoo.ca wrote:
Thanks for all the replies. I've opted to use p2open which will allow
the 32bit executable to write to stdout to 64bit's stdin. The 64bit
executable will then write to stdout and the 32bit will read it.
The data generated by one program may not make sense to the other.
I want to make a small tweak though. I would like the 32bit to keep
the pipe open and the 64bit will constantly check to see if there's
anything new written to its stdin. Prior to attempting to modify
this, I was using fprintf and fgets in both programs to write and read
from stdout/stdin. My attempt to do the tweak was to put the entire
64bit program inside a "while (fgets(input, sizeof(input), stdin) !=
NULL)" loop. It doesn't work though. I don't think it is reading the
value.
fgets attempts to either read in a complete line or input-1 characters
and append a null character. If a newline occurs it is retained.
Excessive characters are simply left in the stream's buffers and later
calls to fgets can pick them up.

Try using fgetc or getc.
Before the while loop i opened a log file and inside the loop,
I would write the input to the log file. The log file is created but
there's nothing in the log.

Is there anything wrong with my approach? Thanks.
How can we asses that when there's no code?

Apr 2 '07 #7
Thanks santosh. What I was missing was actually a \n on the 64 bit
side when I do a fprintf to stdout. The 32 bit program hangs at fgets
because it was waiting for something and reading your post reminded me
to check if it's returning a newline character on the 64 bit side.

Thanks!

Apr 2 '07 #8
>Thanks for all the replies. I've opted to use p2open which will allow
>the 32bit executable to write to stdout to 64bit's stdin. The 64bit
executable will then write to stdout and the 32bit will read it.
Beware of deadlock. Buffering makes it worse, and some systems will
*NOT* flush the buffer when a newline is output when writing to a pipe.
Use of fflush() is recommended. Also, you need to know when you've
read all of the result *without* attempting to read more.
>I want to make a small tweak though. I would like the 32bit to keep
the pipe open and the 64bit will constantly check to see if there's
anything new written to its stdin.
ANSI C has no non-blocking I/O. If you call fgets() to read a line,
it keeps waiting until it gets (a) a full line, (b) a full buffer,
or (c) end of file. It will *not* return with "no input yet".
>Prior to attempting to modify
this, I was using fprintf and fgets in both programs to write and read
from stdout/stdin. My attempt to do the tweak was to put the entire
64bit program inside a "while (fgets(input, sizeof(input), stdin) !=
NULL)" loop. It doesn't work though. I don't think it is reading the
value. Before the while loop i opened a log file and inside the loop,
I would write the input to the log file. The log file is created but
there's nothing in the log.

Is there anything wrong with my approach? Thanks.
Apr 2 '07 #9
Gordon Burditt said:
>>Thanks for all the replies. I've opted to use p2open which will allow
the 32bit executable to write to stdout to 64bit's stdin. The 64bit
executable will then write to stdout and the 32bit will read it.

Beware of deadlock.
Gordon, when are you going to learn to ascribe quotes?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Apr 3 '07 #10
When will certain posters stop posting articles that don't add
anything about C? Top-posting, Google, topicality, attributions,
and calling other posters names are off-topic. If you (and you
know who you are) must do that, how about talking about C also?

If your system allows you to compile to binaries of different types,
like 64-bit vs. 32-bit, you probably want to transfer text between
them over pipes. Raw images of structures probably won't have the
same size, alignment, or whatever in both binaries.
Apr 8 '07 #11
go***********@burditt.org (Gordon Burditt) writes:
When will certain posters stop posting articles that don't add
anything about C? Top-posting, Google, topicality, attributions,
and calling other posters names are off-topic. If you (and you
know who you are) must do that, how about talking about C also?
Gordon, when are you going to learn to ascribe quotes?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 8 '07 #12
Gordon Burditt said:
When will certain posters stop posting articles that don't add
anything about C? Top-posting, Google, topicality, attributions,
and calling other posters names are off-topic.
Wrong. Discussions about topicality are, alas, always topical. And your
apparent desire to stop people complaining about your continual failure
to ascribe quoted text would be most easily satisfied if you were to
ascribe the text that you quote.
If you (and you
know who you are) must do that, how about talking about C also?
That'd be nice, yes.
If your system allows you to compile to binaries of different types,
like 64-bit vs. 32-bit, you probably want to transfer text between
them over pipes.
Well, we're hardly talking about C now, are we?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Apr 8 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kenton | last post by:
Does anyone know if Oracle forgot to put the OEM tools in the 9.2.0.4 Linux x86-64 version of their download? I have installed both the database and the client tools and cannot find the emca tool...
4
by: muroogan | last post by:
I read a text file into a char variable char tchar; I want to trim leading spaces (Left trim).How can I do that in C++. Any input will be appreciated.
54
by: Lionel Valero | last post by:
Hello, I have a test program that is compiled fine on a 32 bits redhat linux using gcc : *********************** main (argc, argv) int argc; char *argv; { int *ka; int nka;
56
by: Dave Vandervies | last post by:
I just fixed a bug that some of the correctness pedants around here may find useful as ammunition. The problem was that some code would, very occasionally, die with a segmentation violation...
1
by: osaleh | last post by:
I am trying to execute a Socket.Select() statement on an arraylist of sockets. The problem is that I can only go up to 64 sockets at a time. I know that I have to manupilate the FD_SetSize to...
4
by: Raed Sawalha | last post by:
I have list of name separated by comm like this name1,name2,name3,...etc i converted then to Base-64 using Convert.ToBase64String() then pass them to webmethod then i when try to get data back to...
9
by: Stuart | last post by:
I am trying to execute a Socket.Select() statement on an arraylist of sockets. The problem is that I can only go up to 64 sockets at a time. I know that I have to manipulate the FD_SetSize to...
13
by: Mary Lei | last post by:
Does anyone know the link to obtain the tarball for db2 8.1 for solaris running on AMD 64 bit ? This is the entire db2 installation on a new system that does not have db2. Thanks.
1
by: =?Utf-8?B?UGF1bCBQaGlsbGlwcw==?= | last post by:
I have read many things about this but I haven't got a clear vision on what to do if anything about this. I have a system that tries to find holes in my web site. One of the things it has...
7
by: Medvedev | last post by:
what's the meaning of the number 64 in the function fopen64?!!! i know fopen64 used to open big files but what 64 refer to and how much the usual fopen can open - pls explain
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.