Listening to UDP sockets
Burton Radons
burton-radons at smocky.com
Fri Feb 23 11:26:48 PST 2007
Burton Radons wrote:
> I have this code:
>
> import std.socket;
>
> void main ()
> {
> auto address = new InternetAddress (3333);
> auto socket = new UdpSocket ();
> socket.bind (address);
> socket.listen (10);
> }
>
> Which fails during execution on the "listen" line with "Error: Unable to
> listen on socket". Can anyone help? Replacing "Udp" with "Tcp" lets it
> work properly so perhaps this is a bug in "std.socket".
I figured it out - I just have to bind (no listen) and then the receive
buffer must be large enough to contain the entire message or it either
never returns (since it's waiting for a datagram which is small enough
to fit, I guess) or returns -1 in nonblocking mode. I knew there were no
socket connections in the TCP sense but I was expecting sockets to
simulate it in order to have one unified API.
More information about the Digitalmars-d-learn
mailing list