UDP socket, sending 270+ bytes crashes receiver
BlitzMax Forums/BlitzMax Programming/UDP socket, sending 270+ bytes crashes receiver
| ||
EDIT: nevermind this please, has been resolved :) I realize I have posted this in the bugs section, but that might've been a bit rushed, it's probably my smelly code doing the troubles.. Can anyone help me maybe? I send a string of more than 270 bytes it'll crash the receiving end.. For instance if client sent 271 bytes to server, the server will crash with no sort of errorcode whatsoever. Is that normal behavior? 270 bytes seems an odd limit. I'm doing it over UDP sockets like this: SENDER: Method send(stringtosend$,flags=0) If Not socket Then Return Local byte_ptr:Byte Ptr = stringtosend.tocstring() Local recvlength = socket.send( byte_ptr, stringtosend.length, Flags ) Return recvlength EndMethod RECEIVER: (the one that crashes). Using socket.readavail() for the length. Obviously only calling the function below when there's data to receive. Function recvfromsocket$(socket:tsocket, length, remoteip Var, remoteport Var, flags = 0) If socket = Null Then RuntimeError("aghggg") If length <= 0 Then RuntimeError("agh") Local bytes:Byte[] Local senderip,senderport Local recvlength = recvfrom_( socket._socket, bytes, length , flags, senderip,senderport ) If recvlength < 0 Then Return remoteip = senderip ; remoteport = senderport Local data$ = String.FromBytes( Bytes, Recvlength ) If Not data Then RuntimeError("wtffff") Return data$ EndFunction |
| ||
Hello. Your array bytes is not initialized. Make space for receive data: local bytes:Byte[]=new Byte(x) x is max amount of bytes Bye, Paposo |
| ||
Yep that was the problem, skidracer pointed it out to me in the bugs forum, which is why I asked at the top of this post to pay it no mind :) But thank you Paposo! :) |