voov 2 the scroobening
This commit is contained in:
parent
fc2d863e11
commit
eaac4f0948
8 changed files with 68 additions and 26 deletions
48
src/server/sock/tcp.h
Normal file
48
src/server/sock/tcp.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
#ifndef GLV_SOCK_TCP_H
|
||||
#define GLV_SOCK_TCP_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#ifdef __MINGW32__
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT _WIN32_WINNT_WIN8
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
typedef GLV_SOCK_T SOCKET;
|
||||
typedef GLV_ADDR_T SOCKADDR_
|
||||
|
||||
#define GLV_SOCK_T SOCKET
|
||||
#define GLV_ADDR_T SOCKADDR_IN
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define GLV_SOCK_T int
|
||||
#define GLV_ADDR_T struct sockaddr_in
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define GLV_TCP_FLAG_TYPE 1
|
||||
#define GLV_TCP_FLAG_NBIO 2
|
||||
|
||||
typedef struct {
|
||||
uint32_t flags;
|
||||
} tcp_t;
|
||||
|
||||
tcp_t* tcp_create_server();
|
||||
tcp_t* tcp_create_client();
|
||||
|
||||
|
||||
|
||||
void tcp_destroy(tcp_t* socket);
|
||||
|
||||
#endif
|
5
src/server/sock/tcp_bsd.c
Normal file
5
src/server/sock/tcp_bsd.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef _WIN32
|
||||
#include "tcp.h"
|
||||
|
||||
|
||||
#endif
|
|
@ -1,2 +1,2 @@
|
|||
#include "tcp_win.h"
|
||||
#include "tcp.h"
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef GLOVE_SOCK_TCP_H
|
||||
#define GLOVE_SOCK_TCP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define TCP_FLAG_TYPE 1
|
||||
#define TCP_FLAG_NONBLOCKING 2
|
||||
|
||||
typedef struct {
|
||||
uint32_t flags;
|
||||
} tcp_t;
|
||||
|
||||
tcp_t* tcp_create_server();
|
||||
tcp_t* tcp_create_client();
|
||||
|
||||
void tcp_destroy(tcp_t* socket);
|
||||
|
||||
#endif
|
|
@ -1,5 +0,0 @@
|
|||
//
|
||||
// Created by alec on 12/20/2018.
|
||||
//
|
||||
|
||||
#include "thread.h"
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef GLOVE_UTIL_THREAD_H
|
||||
#define GLOVE_UTIL_THREAD_H
|
||||
#ifndef GLV_UTIL_THREAD_H
|
||||
#define GLV_UTIL_THREAD_H
|
||||
|
||||
#endif
|
||||
|
|
6
src/server/util/thread_posix.c
Normal file
6
src/server/util/thread_posix.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef _WIN32
|
||||
#include "thread.h"
|
||||
|
||||
|
||||
|
||||
#endif
|
6
src/server/util/thread_win.c
Normal file
6
src/server/util/thread_win.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifdef _WIN32
|
||||
#include "thread.h"
|
||||
|
||||
|
||||
|
||||
#endif
|
Reference in a new issue