Socket.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Socket_H
  16. #define Socket_H
  17. #include "memory/Allocator.h"
  18. #include "util/platform/Sockaddr.h"
  19. #include "util/Linker.h"
  20. Linker_require("util/platform/Socket.c")
  21. #include <stdint.h>
  22. #define Socket int
  23. int Socket_makeNonBlocking(int sock);
  24. int Socket_makeReusable(int sock);
  25. int Socket_close(int sock);
  26. int Socket_recv(int sockfd, void* buff, unsigned long bufferSize, int flags);
  27. int Socket_recvfrom(int fd,
  28. void* buff,
  29. unsigned long bufferSize,
  30. int flags,
  31. struct Sockaddr_storage* ss);
  32. int Socket_connect(int fd, const struct Sockaddr* sa, struct Allocator* alloc);
  33. const int Socket_SOCK_DGRAM;
  34. const int Socket_SOCK_STREAM;
  35. int Socket_socket(int af, int type, int protocol, struct Allocator* alloc);
  36. int Socket_bind(int fd, const struct Sockaddr* sa);
  37. int Socket_send(int socket, const void *buffer, unsigned long length, int flags);
  38. int Socket_sendto(int fd,
  39. const void* buffer,
  40. unsigned long len,
  41. int flags,
  42. const struct Sockaddr* destination);
  43. int Socket_accept(int fd, struct Sockaddr_storage* addr, struct Allocator* alloc);
  44. int Socket_getsockname(int sockfd, struct Sockaddr_storage* addr);
  45. #endif