Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
432 B

21 years ago
21 years ago
21 years ago
  1. #include <sys/types.h>
  2. #include <sys/param.h>
  3. #include <sys/socket.h>
  4. #include <netinet/in.h>
  5. #include "byte.h"
  6. #include "socket.h"
  7. #include "havesl.h"
  8. int socket_local4(int s,char ip[4],uint16 *port)
  9. {
  10. struct sockaddr_in si;
  11. socklen_t len = sizeof si;
  12. if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return -1;
  13. *(uint32*)ip = *(uint32*)&si.sin_addr;
  14. uint16_unpack_big((char *) &si.sin_port,port);
  15. return 0;
  16. }