• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Seeking basic example in C/C++ using the Process-to-Process Communication Toolbox

pfuentes69

Well-known member
Hello,
for a project I want to send short messages from an app to another in a different Mac (both running System 7).
I was pointed to the Process-to-Process Communication Toolbox documentation, but I'm not clever enough to build a working program in C using the code snippets in Pascal.

Is someone aware of a working example in C? I checked the books I have but none gets into this Toolbox.

Txs!
 

Phipli

Well-known member
I'd start by looking in the examples that come with CodeWarrior for sending apple events between applications... @cheesestraws or @Crutch may be able to give you more specific directions.
 

Crutch

Well-known member
The best place to find examples are the MacTech archive (for example http://preserve.mactech.com/articles/mactech/Vol.14/14.11/Client-ServerDevelopment/index.html ) and old MacTech and Develop CDs (available on macintoshgarden).

The MacTech article I linked just above appears to provide a simple C++ implementation of some code to use the PPC Toolbox, though I haven’t read it in depth.

In general though, the source for this type of information would be Inside Macintosh: Interapplication Communication (1993), of which the full text is available here https://vintageapple.org/inside_r/pdf/Interapplication_Comm_1993.pdf. Unfortunately 1993 predates when Apple started first-class support of C code/examples in its documentation. That said, being able to visually translate from Pascal to C is sort of a 101-level requirement of writing 68k Mac code, due to the Toolbox’s roots as an API intended to be called from either Pascal or assembly language. So if you want to write Mac code but aren’t comfortable reading Pascal code, you may want to invest in picking up that skill first.

If there are specific bits of Pascal you are having trouble converting to C, post them here and I’m happy to help.

What specifically do you want your project to do? It is also possible there are more specific applicable examples floating around somewhere.
 

cheesestraws

Well-known member
I learned what little I know about Apple Events from exactly the sources that @Crutch mentioned: mactech and the Apple Develop magazine. There is sample code on the developer sample CDs.

The Apple Events system feels complex when you look at it first, but it isn't that bad: I find it helps to remember that you are basically writing by hand the stuff that AppleScript compiles to. It's very different philosophically from UNIX IPC, for example, because you're very much talking about structured data.

I don't currently have the time or energy to knock up a more specific example, I'm afraid - work is doing me in at the moment. If life returns to normal any time soon I'll try to be more specific.
 

pfuentes69

Well-known member
Thanks @Crutch and @cheesestraws
I'll look calmly to the doc and available examples, and maybe come back with specific questions (this can take weeks, tough, as I have little spare time myself for this)
 

joevt

Well-known member
If you know Unix, GUSI might be a useful alternative? It implements pthreads and sockets for Mac OS. Even if you don't know Unix, there's plenty of sample source code related to sockets.

Code:
                 GUSI 2 -- A multithreaded POSIX library
INTRODUCTION

GUSI is an extension and partial replacement of the standard C runtime library
supplied with your compiler. The main objective of GUSI is to faciliate the 
porting of software written for UNIX systems by implementing a substantial subset
of the Single Unix Specification library routines:

 - BSD style sockets.
 - Pthreads.
 - Many other POSIX facilities such as diropen().

REQUIREMENTS

To use GUSI, you need one of the following compilers:

 - Metrowerks CodeWarrior Pro 5 or later.
 - SC/SCpp 8.8.4d1c1 or later.
 - MrC/MrCpp 4.1.0a6c1 or later.
 

pfuentes69

Well-known member
If you know Unix, GUSI might be a useful alternative? It implements pthreads and sockets for Mac OS. Even if you don't know Unix, there's plenty of sample source code related to sockets.
Thanks. Please note that I want to do something for System 7
 
Top