beginning rewrite feels

This commit is contained in:
malloc 2018-02-16 16:34:22 -06:00
parent 3af57b7aeb
commit 6087d8261a
10 changed files with 119 additions and 4 deletions

View file

@ -1,3 +1,4 @@
set(CMAKE_CONFIGURATION_TYPES "Debug" CACHE STRING "" FORCE)
cmake_minimum_required(VERSION 2.6)
project(server)

View file

@ -2,7 +2,9 @@
#include "sock/tcpsock.hpp"
int main(int argc, char **argv) {
auto sock = TcpClient();
//auto sock = sosc::TcpClient();
std::cout << "compiled on windows" << std::endl;
return 0;
}

2
server/src/sock/ip.cpp Normal file
View file

@ -0,0 +1,2 @@
#include "ip.hpp"

12
server/src/sock/ip.hpp Normal file
View file

@ -0,0 +1,12 @@
#ifndef SOSC_UTIL_IP_H
#define SOSC_UTIL_IP_H
namespace sosc {
class IpAddress {
protected:
};
}
#endif

View file

@ -1,6 +1,41 @@
#include "tcpsock.hpp"
TcpClient::TcpClient() {
std::cout << "test" << std::endl;
/****************************/
/* BEGIN TCPCLIENT CODE */
/****************************/
#ifdef _WIN32
sosc::TcpClient::TcpClient() {
this->sock_open = false;
this->addr_len = -1;
}
bool sosc::TcpClient::Init(std::string host, std::uint16_t port) {
if(this->sock_open)
return false;
struct addrinfo hints, *result, *ptr;
}
#else
#endif
/****************************/
/* END TCPCLIENT CODE */
/****************************/
/* BEGIN TCPSERVER CODE */
/****************************/
#ifdef _WIN32
sosc::TcpServer::TcpServer() {
}
#else
#endif
/****************************/
/* END TCPSERVER CODE */
/****************************/

View file

@ -1,15 +1,52 @@
#ifndef SOSC_TCPSOCK_H
#define SOSC_TCPSOCK_H
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#define SOSC_SOCK_T SOCKET
#define SOSC_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 SOSC_SOCK_T int
#define SOSC_ADDR_T struct sockaddr_in
#endif
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define SOSC_TCP_BUFLEN 2048
namespace sosc {
class TcpClient {
public:
TcpClient();
bool Init(std::string host, std::uint16_t port);
~TcpClient();
protected:
bool Init(SOSC_SOCK_T sock, SOSC_ADDR_T addr, int addr_len);
SOSC_SOCK_T sock;
bool sock_open;
SOSC_ADDR_T addr;
int addr_len;
char buffer[SOSC_TCP_BUFLEN];
friend class TcpServer;
};
class TcpServer {
@ -18,7 +55,8 @@ public:
~TcpServer();
protected:
SOSC_SOCK_T sock;
};
}
#endif

2
server/src/utils/net.cpp Normal file
View file

@ -0,0 +1,2 @@
#include "net.hpp"

10
server/src/utils/net.hpp Normal file
View file

@ -0,0 +1,10 @@
#ifndef SOSC_UTIL_NET_H
#define SOSC_UTIL_NET_H
namespace sosc {
namespace util {
namespace net {
}}}
#endif

View file

@ -0,0 +1,3 @@
#include "string.hpp"
using namespace sosc::util::str;

View file

@ -0,0 +1,10 @@
#ifndef SOSC_UTIL_STRING_H
#define SOSC_UTIL_STRING_H
namespace sosc {
namespace util {
namespace str {
}}}
#endif