Skip to content
Advertisement

Sendto returning random values

I call sendto in my udp socket client side like this:

JavaScript

but there seems to be no nothing received at the server side and in very strange fashion, num_w, when printed out, gives values like:

-197379208 -1440076936 2054978424

And perror() displays “success”

Client code up till that point:

JavaScript

Thanks so much in advance! (Oh and I’m on Kali linux, virtual machine, Windows 10)

Advertisement

Answer

You aren’t printing num_w. You’ve left it out of the printf() statement. You’re just printing whatever random junk is on the stack.

And perror() displays “success”

So num_w was positive. Calling perror() in that case is pointless.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement