summaryrefslogtreecommitdiff
path: root/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'tcp.h')
-rw-r--r--tcp.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/tcp.h b/tcp.h
index 6d50538..66d4c75 100644
--- a/tcp.h
+++ b/tcp.h
@@ -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);