mIRC Home    About    Download    Register    News    Help

Print Thread
#270190 17/04/22 09:03 PM
Joined: Oct 2017
Posts: 47
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Oct 2017
Posts: 47
Hi!! cry sick confused

I attempting to use udpread event but seems that non-binary way doesn't reading the bytes correctly even if $sockbr is not $null there. The fail seems to be on /sockread %temp under server2 udpread event that doesn't saving the data. i will provide a short reproduce code.

Reproduce Code :

Code
ON *:UDPREAD:server1: {
  if ($sockerr) { echo 4 -sg Sockerr $sockname > $sockerr --> $sock($sockname).wsmsg | return }

  sockread $sock($sockname).rq &temp

  if ($sockbr) { echo 12 -sg $sockname -- $sockbr -- $bvar(&temp,0) -- $bvar(&temp,1-) -- $bvar(&temp,1-).text }
}

ON *:UDPREAD:server2: {
  if ($sockerr) { echo 4 -sg Sockerr $sockname > $sockerr --> $sock($sockname).wsmsg | return }

  var %temp
  sockread %temp

  if ($sockbr) { echo 13 -sg $sockname -- $sockbr -- %temp }
}

alias fast_test {
  sockclose server1
  sockclose server2

  sockudp -k server1 7901
  sockudp -k server2 7902

  bset &temp -1 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 51 50 32 45 32 49 53 58 49 55 58 48 57 58 32 10 0

  var %t = 3
  while (%t) { sockudp client1 127.0.0.1 7901 &temp | sockudp client2 127.0.0.1 7902 &temp | dec %t }
}

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
The line you are sending ends in a zero byte. When /sockread reads into %temp, it reads up to the first LF character. The next read starts at the zero byte in the stream and again reads up to the next LF character. And so on. You need to decide when sending the data whether you want it to be treated as binary or text and then make sure that the receiving /sockread acts accordingly.


Link Copied to Clipboard