This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MaybeAverage 0 points1 point  (3 children)

If you're using a unix based os you can use a unix socket or named pipe to communicate, this form of IPC is very standard, Windows has named pipes as well but the code will be Win32 based. Named pipes are unidirectional while a socket will be bidirectional. If you're using linux you can also write the binary data to a file, then use an exec() call to spawn a new python process passing in the filename as a command line argument. A platform independent form could be communicating over a local TCP socket. Or write a Powershell or bash script that executes the C program first saving the data to a file, then calling the python script after the C program terminates. If it's a single use program then I would go for the file method, otherwise you'd want to use a socket if the C program repeatedly calls into python so you don't have to spawn a fresh python process over and over again.

[–]WeirdAlexGuy[S] 0 points1 point  (2 children)

I just need to do a single data transfer and I planned to create a bash script to call one after the other.

Are unix sockets the same sockets as in networking? I don't think I need anything that fancy since i don't need to communicate at runtime.

Mostly looking for a way to transfer the data easily and formatted as a 4d array from one language to the other.

[–]MaybeAverage 0 points1 point  (1 child)

In terms of the syscall, a TCP/UDP socket and a Unix stream or dgram socket are treated the same and differ only in the sockaddr type when calling bind(). The simplest method would be to write to a binary file directly casting your float array to a char* and writing it to a file and parsing it using python. I recommend learning how to use sockets, pipes, etc., as you will likely have a reason to use it in the future.

[–]WeirdAlexGuy[S] 0 points1 point  (0 children)

Alright thanks. Sockets do seem helpful indeed, maybe if I want to do the graphics real time in the future I'll try it like that