I am new to perl. I need to write a golang code which read UDP package sent from a perl UDP socket client. Basically, the perl client packs data using the template "N/a* N/a*" like the following:
$them = pack($sockaddr,&AF_INET, $data_port, $broadaddr);
$actual_data = pack("N/a* N/a*", $string1, $string2);
send(S,$actual_data,0,$them) || die $!;
My question is:
- What does "N/a* N/a*" actually means? A simple explanation would be helpful. How two strings are actually packed?
- How i can write a similar packing function in golang given two unicode strings; and if I got a packed buffer sent from perl UDP client, how i can write a corresponding function "in golang" to unpack it. Is there any library which can handle this so that I can use golang on par with perl for socket programming.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…