multiple connections in UDP server

Started by
11 comments, last by hplus0603 11 years, 8 months ago
Thanks a lot!
Advertisement

Omg, such a stupid detail... int addrlen = sizeof(sockaddr_in); helped. Honestly I've got no idea why it really has to be so but the problem is solved now and it seems to support more than 1 client biggrin.png.Thanks a lot papalazaru!


I'm surprised this hasn't blown up in your face tbh. Although the function most likely reads from the location at address sizeof(sockaddr_in), which would be 0x00000010 or there about, and not write to it, it should still throw an access violation.

In any case, always handle your errors correctly. You should call WSALastError() and this would have retuned WSAEINVAL, or invalid argument.

Everything is better with Metal.

Access errors in kernel space generally returns an error, rather than actually raise an exception.
Each system call actually first validates the reachability of all argument data areas before dispatching, and if it's a bad address, returns an error.
Btw: This makes certain system calls on Linux (such as ioctl()) very hard to implement robustly.

Anyway, to the OP saying "no idea why it really has to be so," the difference between a pointer to a value, and the value itself, is fundamental to programming in C or C++. If you don't understand the difference, then you should not yet be trying network programming.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement