base
This commit is contained in:
parent
0286bd63f1
commit
6a68ba0bd0
7 changed files with 78 additions and 8 deletions
|
|
@ -1 +1,26 @@
|
|||
#include <GearSrc/Net.h>
|
||||
|
||||
#include <GearSrc/Log.h>
|
||||
|
||||
GSNetClient GSNetClientOpen(GSClient client, const char* hostname, int port) {
|
||||
GSNetClient net = malloc(sizeof(*net));
|
||||
|
||||
memset(net, 0, sizeof(*net));
|
||||
|
||||
net->engine = client->engine;
|
||||
|
||||
if((net->fd = GSNetBaseClient(hostname, port)) < 0) {
|
||||
GSLog(client->engine, GSLogError, "Failed to initialize socket");
|
||||
GSNetClientClose(net);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return net;
|
||||
}
|
||||
|
||||
void GSNetClientClose(GSNetClient client) {
|
||||
if(client->fd >= 0) GSNetBaseClose(client->fd);
|
||||
|
||||
free(client);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue