pack or udp ?

Started by newdep, July 28, 2004, 07:05:43 AM

Previous topic - Next topic

newdep

Hello Lutz,



Perhaps you can clarify my problem..



this is the string im sending



(net-send-udp "127.0.0.1" 5000 (pack "c c s7 c s4 c" (char 0) (char 1) text012" (char 0) "text" (char 0)))



But im receiving every time a different binary string on the listener side?



I you try to send the message above several times towards an (net-receive-udp 5000 128 ) and unpack the binarydata,

you will see that somting is wrong.. Although overhere its wrong..

perhpas its in the combined function call?



I dont see it... perhpas its the pack combination of srings and bytes? Or

perhpas its the x0 byte in the udp packet? or just a complete from function of mine ?



Regards, Norman.
-- (define? (Cornflakes))

Lutz

#1
(char 0) is not a number but a string! the format character 'c' is expecting a number between 0 -> 255 for a character (see manual), just like in the 'C' language. newLISP will take the address of the string and stuff the lower 8 bit into c, which is something different each time, when a new string gets allocated by (char 1) or (char 0) what you want to do is:





(pack "c c s7 c s4 c" 0 1 "text012" 0 "text" 0) => "0001text01200text00"



this will always give you the same results.



Lutz

newdep

#2
Ieeeekkksss ... second time im doing this wrong ;-)

thanks!
-- (define? (Cornflakes))