sendto.c 502 B

12345678910111213141516171819202122232425262728
  1. /* posix */
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #include <fcntl.h>
  5. #include <errno.h>
  6. /* bsd extensions */
  7. #include <sys/uio.h>
  8. #include <sys/socket.h>
  9. #include "priv.h"
  10. int
  11. sendto(int fd, void *a, int n, int flags,
  12. void *to, int tolen)
  13. {
  14. /* actually, should do connect if not done already */
  15. return send(fd, a, n, flags);
  16. }
  17. int
  18. recvfrom(int fd, void *a, int n, int flags,
  19. void *from, int *fromlen)
  20. {
  21. if(getsockname(fd, from, fromlen) < 0)
  22. return -1;
  23. return recv(fd, a, n, flags);
  24. }