Thanks infratec, I since read about it being "connectionless", as it says in the docs. Actually, the way I need to do this is for the "calling" routine to send data to the "called" routine, and for the "called" routine to send data back. Do I need to open a UDP server at both ends with different port numbers? It's already working as a "called" prog receiving data and proving it by putting it into a file (both below). It's a background process that doesn't need a console display.infratec wrote: Thu Oct 20, 2022 7:39 pm No, I mean you don't need to handle: #PB_NetworkEvent_Connect #PB_NetworkEvent_Disconnect
Code: Select all
; ** Mainprog.pb - Main calling routine
OpenConsole()
If RunProgram("d:\udpprog\subprog.exe", "", "", #PB_Program_Open )
ConnectionID = OpenNetworkConnection("127.0.0.1", 24 , #PB_Network_UDP, 5000 )
Repeat
Print("Please enter a string to send to the background process 'subprog.pb' or q to quit : ")
str$ = Input()
SendNetworkString(ConnectionID, str$, #PB_Unicode);
If str$="q"
End
EndIf
ForEver
EndIf
Code: Select all
; ** d:\udpprog\Subprog.pb - Sub prog routine
*Buffer = AllocateMemory(1000)
If CreateNetworkServer(0, 24, #PB_Network_IPv4 | #PB_Network_UDP, "127.0.0.1")
Repeat
ServerEvent = NetworkServerEvent()
If ServerEvent
ClientID = EventClient()
Select ServerEvent
Case #PB_NetworkEvent_Data
result.i = ReceiveNetworkData(ClientID, *Buffer, 1000)
strinp$=Left(PeekS(*Buffer, -1, #PB_Unicode),result.i)
output.s + strinp$
If Left(strinp$,1) = "q"
CreateFile(0,"d:\udpprog\output.txt")
WriteString(0,output.s)
CloseFile(0)
quit = 1
EndIf
EndSelect
EndIf
Until Quit = 1
EndIf