diff options
Diffstat (limited to 'tcp.h')
-rw-r--r-- | tcp.h | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -30,6 +30,26 @@ typedef struct TcpList{ TcpList* tcp_read_list(int sock,const char *tag); void tcp_list_destroy(TcpList *list); +typedef enum TcpResponseType{ + TCP_OK, + TCP_LIST, + TCP_INT, + TCP_ERROR, +} TcpResponseType; + +typedef struct TcpResponse{ + TcpResponseType type; + union { + TcpList *lval; + i64 ival; + char *eval; //Newly allocated string + }; +} TcpResponse; + +//Returns NULL on error instead of -1. +TcpResponse* tcp_read_response(int sock,const char *tag); +void tcp_response_destroy(TcpResponse *res); + //Returns the socket. int tcp_connect(const char *hostname,int port); |