UDP Client memory access violation

Blitz3D Forums/Blitz3D Beginners Area/UDP Client memory access violation

MartinB(Posted 2007) [#1]
Currently im working on a game theres need to access a server through a UDP stream I have try lot difference things for get this to work, none so far working. What I need to do is make a udp stream. Send a msg to the host. Receive msg. The first two things are working perfectly the last, receiveing a msg is making a Memory access Violation. Heres my c/p code so far.

; Init streaming.
stream = CreateUDPStream()
If Not stream Then error("could't connect To host.")



WriteLine stream,"hello world"
CountHostIPs("127.0.0.1")
SendUDPMsg stream,HostIP(1),1989

While (True)
Delay(1000)
recv = RecvUDPMsg(stream)

If recv <> 0 Then
msg$ = ReadString(stream)
Print(msg$)
EndIf

Wend


The server is fully tested, I used nc for test it and its the not issue.

Regards


Carolinaaa(Posted 2007) [#2]
If you are using both the server and client in the same local computer, perhaps the problem is that you are creating the udp stream on both server and client in the same port.

You may use the same port number for the upd messages if the server is placed on a different computer, but if both are in the same computer, creating a second udp stream in the same port cause such error.


MartinB(Posted 2007) [#3]
I found out why, ReadString reads until reach 0x0, But I never sended a 0x0
Ty for reply


Regards


Sir Gak(Posted 2007) [#4]
@MartinB:
"I found out why, ReadString reads until reach 0x0, But I never sended a 0x0
Ty for reply"

Isn't it more satisfying to find the error yourself, instead of having someone else find it? I'm not knocking getting help when we need it, but I find it FEELS a bit more triumphant when I was the one who found the bug.