Network.recvFrom strangeness
Peter Simons
simons at cryp.to
Tue Sep 23 15:52:50 EDT 2003
The declaration of Network.recvFrom looks strange:
recvFrom :: HostName -> PortID -> IO String
I thought that recvFrom should _return_ the address of the peer, not
require it as an argument? At least that's what the corresponding
4.4BSD routine does:
| ssize_t recvfrom(int s, void *buf, size_t len, int flags,
| struct sockaddr *from, socklen_t *fromlen);
|
| DESCRIPTION
| The recvfrom and recvmsg calls are used to receive messages
| from a socket, and may be used to receive data on a socket
| whether or not it is connection-oriented.
|
| If from is not NULL, and the socket is not connection-oriented,
| the source address of the message is filled in. The argument
| fromlen is a value-result parameter, initialized to the size of
| the buffer associated with from, and modified on return to
| indicate the actual size of the address stored there.
By the way: I am not sure whether HostName is the appropriate type
here! IMHO the routine should rather return the _address_ of the peer,
not the hostname. (For example, what does it return when the resolver
fails?)
Peter
More information about the Libraries
mailing list