12345678910111213141516171819202122232425262728293031323334 |
- /*
- * Copyright (C) 2019-2020 Alibaba Group Holding Limited
- */
- #ifndef __NETWORK_H__
- #define __NETWORK_H__
- #include <sys/socket.h>
- #include <arpa/inet.h>
- #ifndef __linux__
- #include <lwip/netdb.h>
- #else
- #include <netdb.h>
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef struct network {
- int fd;
- struct sockaddr_in address;
- int (*net_connect)(struct network *n, char *addr, int port, int net_type);
- int (*net_read)(struct network *, unsigned char *, int, int);
- int (*net_write)(struct network *, unsigned char *, int, int);
- void (*net_disconncet)(struct network *n);
- } network_t;
- void network_init(network_t *n);
- #ifdef __cplusplus
- }
- #endif
- #endif
|