Add Inter-Process Communication
This commit is contained in:
parent
46cdaf4e63
commit
19bf4b5288
4 changed files with 423 additions and 1 deletions
44
test_ipc.bas
Normal file
44
test_ipc.bas
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
$console:only
|
||||
declare library "terminkey"
|
||||
function ipc_init&()
|
||||
function ipc_check_message%(byval buf as _offset, byval max_len as long)
|
||||
sub ipc_send_message(buf as string)
|
||||
sub ipc_cleanup()
|
||||
sub get_absolute_path(rel_path as string, byval abs_path as _offset, byval max_len as long)
|
||||
end declare
|
||||
|
||||
dim r as long
|
||||
r = ipc_init
|
||||
print "ipc_init returned:"; r
|
||||
|
||||
if r = 1 then
|
||||
print "We are the server! Waiting for a message..."
|
||||
dim msg as string
|
||||
msg = space$(100) + chr$(0)
|
||||
dim start_time as double
|
||||
start_time = timer
|
||||
do while timer - start_time < 3
|
||||
dim n as long
|
||||
n = ipc_check_message(_offset(msg), 100)
|
||||
if n > 0 then
|
||||
print "Received: "; left$(msg, n)
|
||||
exit do
|
||||
end if
|
||||
_limit 10
|
||||
loop
|
||||
ipc_cleanup
|
||||
elseif r = 0 then
|
||||
print "We are the client! Sending a message..."
|
||||
ipc_send_message "Hello from client!"
|
||||
else
|
||||
print "Error initializing IPC"
|
||||
end if
|
||||
|
||||
dim rel as string
|
||||
rel = "readme.md"
|
||||
dim abs_path as string
|
||||
abs_path = space$(512) + chr$(0)
|
||||
get_absolute_path rel, _offset(abs_path), 512
|
||||
print "Absolute path of '"; rel; "' is: '"; _trim$(abs_path); "'"
|
||||
|
||||
system
|
||||
Loading…
Add table
Add a link
Reference in a new issue