diff options
Diffstat (limited to '')
-rw-r--r-- | src/client.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/client.c b/src/client.c index f0c0d3b..8cfb1d1 100644 --- a/src/client.c +++ b/src/client.c @@ -6,18 +6,18 @@ */ #include "client.h" +#include "compiler.h" #include "log.h" #include "msg.h" #include "net.h" #include <stdlib.h> -#include <unistd.h> struct client { - int fd; + int dummy; }; -int client_create(struct client **_client, const struct settings *settings) +int client_create(struct client **_client) { int ret = 0; @@ -27,27 +27,17 @@ int client_create(struct client **_client, const struct settings *settings) return -1; } - ret = net_connect(settings->host, settings->port); - if (ret < 0) - goto free; - client->fd = ret; - *_client = client; return ret; - -free: - free(client); - - return ret; } void client_destroy(struct client *client) { - log_errno_if(close(client->fd), "close"); free(client); } -int client_main(const struct client *client, const char **argv) +int client_main(UNUSED const struct client *client, const struct settings *settings, + const char **argv) { struct msg *request = NULL, *response = NULL; int ret = 0; @@ -56,7 +46,7 @@ int client_main(const struct client *client, const char **argv) if (ret < 0) return ret; - ret = msg_send_and_wait(client->fd, request, &response); + ret = msg_connect_and_communicate(settings->host, settings->port, request, &response); if (ret < 0) goto free_request; |