Linux UDP server
Posted: Sun May 04, 2025 6:19 am
Hi all,
So I'm trying to make something that involves UDP for certain things. I have been at this all day and I'm not sure what might be the issue here. I've attempted to distill this down to just listening on a port and spitting out whatever text is sent. I keep getting invalid memory access.
Now I attempt to test it by using netcat to send a simple message, I use the following command.
I'm not sure what is going on here or if I perhaps discovered a bug. I've tried setting addr to 0.0.0.0 as well and no luck. I'm aware the max UDP buffer is 2048 as well so the one I created is smaller. I've looked on here as well, no real luck either.
I'm running Kubuntu 25.04, but everything else as far as purebasic goes seems to work just fine. If anyone has any clues I'd appreciate it. Though part of me suspects its a case of I overlooked something again.
So I'm trying to make something that involves UDP for certain things. I have been at this all day and I'm not sure what might be the issue here. I've attempted to distill this down to just listening on a port and spitting out whatever text is sent. I keep getting invalid memory access.
Code: Select all
; handwritten UDP mini
#ADDR = "127.0.0.1"
#PORT = 5556
#BUFFER_SIZE = 1024
*buffer = AllocateMemory(#BUFFER_SIZE)
socket = CreateNetworkServer(#PB_Any, #PORT, #PB_Network_UDP)
Repeat
event = NetworkServerEvent()
If event = #PB_NetworkEvent_Data
bytes = ReceiveNetworkData(socket, *buffer, #BUFFER_SIZE)
message.s = PeekS(*buffer, bytes)
Debug message
Debug Str(bytes)
EndIf
Delay(10)
ForEver
Code: Select all
echo -n "JOIN lab1 ALL 127.0.0.1" | nc -u 127.0.0.1 5556
I'm running Kubuntu 25.04, but everything else as far as purebasic goes seems to work just fine. If anyone has any clues I'd appreciate it. Though part of me suspects its a case of I overlooked something again.