| Click here to select a new forum. |
| Seeking basic example in C/C++ using the Process-to-Process Communication Toolbox |
Posted by: pfuentes69 on 2023-10-25 01:13:58 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! |
Posted by: Phipli on 2023-10-25 01:24:43 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. |
Posted by: pfuentes69 on 2023-10-25 01:32:41
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. Indeed I checked that already and I didn't find any, but maybe I didn't look in the right place... |
Posted by: Phipli on 2023-10-25 02:02:39
Indeed I checked that already and I didn't find any, but maybe I didn't look in the right place... Grab a PDF of "Macintosh C Programming Primer" (second edition) from here :
Page 190 onwards talks about apple events, is that any help? |
Posted by: Phipli on 2023-10-25 02:11:03 The red one, Volume I that is, realising it has volume II in the list first.

|
Posted by: pfuentes69 on 2023-10-25 02:46:26
The red one, Volume I that is, realising it has volume II in the list first.
View attachment 64279
View attachment 64280 That may help to start by something! |
Posted by: Crutch on 2023-10-25 09:24:15 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. |
Posted by: cheesestraws on 2023-10-25 16:41:16 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. |
Posted by: pfuentes69 on 2023-10-26 00:16:01 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) |
Posted by: joevt on 2023-10-26 14:51:24 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.
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. |
Posted by: pfuentes69 on 2023-10-27 01:40:08
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 |
Posted by: Snial on 2023-10-27 07:25:47
Thanks. Please note that I want to do something for System 7 IMHO THINK C 5 is the easiest System 7 IDE available. Here's a link to Think C 5:
It's 32-bit clean so that's a good start!
I wrote a little Pascal to C conversion guide, which applies to the Macintosh Pascal Programming primer (which I have instead of the 'C' version):
|
Posted by: joevt on 2023-10-27 14:08:06
Thanks. Please note that I want to do something for System 7 I think GUSI supports 68K. I don't know what System version it requires though.
Do you require the IDE to work in System 7 or just the app that you're creating? |
Posted by: pfuentes69 on 2023-10-30 00:45:52
Do you require the IDE to work in System 7 or just the app that you're creating? I'm building a kind-of home-automation thing for old Macs, so old macOS is required. |
Posted by: robin-fo on 2023-10-30 02:27:27 Oh cool! I‘d now favour AppleTalk instead of AppleEvents |
| 1 |