Clean up for new library code
This commit is contained in:
276
.gitignore
vendored
276
.gitignore
vendored
@ -1,276 +1,2 @@
|
||||
### VisualStudio ###
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.db
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
### C++ ###
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
2
README
2
README
@ -1,3 +1,3 @@
|
||||
# VoidNet
|
||||
|
||||
VoidNet is a networking library built with Windows BSD Sockets for maximum efficiency and readability
|
||||
VoidNet is a networking library built with Windows Sockets for maximum efficiency and reliability
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace VoidNet
|
||||
{
|
||||
enum Protocol
|
||||
{
|
||||
VOID_TCP,
|
||||
VOID_UDP
|
||||
};
|
||||
|
||||
enum SocketType
|
||||
{
|
||||
VOID_CLIENT,
|
||||
VOID_SERVER
|
||||
};
|
||||
}
|
||||
@ -1,189 +0,0 @@
|
||||
#include "Socket.h"
|
||||
#include "Enums.h"
|
||||
|
||||
VoidNet::Socket::Socket(int socketType, int protocolType) :
|
||||
socketType(socketType), protocolType(protocolType)
|
||||
{
|
||||
}
|
||||
|
||||
VoidNet::Socket::Socket(std::string ipAddr, unsigned int port, int socketType, int protocolType) :
|
||||
ipAddr(ipAddr), port(port), socketType(socketType), protocolType(protocolType)
|
||||
{
|
||||
}
|
||||
|
||||
VoidNet::Socket::~Socket()
|
||||
{
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::operator==(Socket &Socket)
|
||||
{
|
||||
//return socket == con.socket;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::operator!=(Socket &Socket)
|
||||
{
|
||||
//return socket != con.socket;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string VoidNet::Socket::getIPAddress()
|
||||
{
|
||||
return ipAddr;
|
||||
}
|
||||
|
||||
std::string VoidNet::Socket::getPeerAddress()
|
||||
{
|
||||
return ipAddr + ":" + std::to_string(port);
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::connectToHost()
|
||||
{
|
||||
if (!init(socketType, protocolType))
|
||||
return false;
|
||||
|
||||
if (connect(soc, addrInfo->ai_addr, addrInfo->ai_addrlen) != SOCKET_ERROR)
|
||||
return true;
|
||||
closesocket(soc);
|
||||
soc = INVALID_SOCKET;
|
||||
freeaddrinfo(addrInfo);
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::sendBytes(const char *buffer, int length)
|
||||
{
|
||||
if (send(soc, buffer, length, 0) == SOCKET_ERROR)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::receiveBytes(char *buffer, int length)
|
||||
{
|
||||
if (recv(soc, buffer, length, 0) == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::shutdownReceive()
|
||||
{
|
||||
if (shutdown(soc, SD_RECEIVE) == SOCKET_ERROR)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::shutdownSend()
|
||||
{
|
||||
if (shutdown(soc, SD_SEND) == SOCKET_ERROR)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::dataAvailable(int &size)
|
||||
{
|
||||
if (ioctlsocket(soc, FIONREAD, (u_long*)size) != NO_ERROR && size > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::dataAvailable()
|
||||
{
|
||||
int s;
|
||||
return dataAvailable(s);
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::setBlocking(bool blocking)
|
||||
{
|
||||
if (ioctlsocket(soc, FIONBIO, (u_long*)(blocking ? 1 : 0)) != NO_ERROR)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int VoidNet::Socket::getPortNumber()
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
||||
bool VoidNet::Socket::init(int socketType, int protocolType)
|
||||
{
|
||||
if (soc != NULL)
|
||||
{
|
||||
try
|
||||
{
|
||||
shutdownReceive();
|
||||
shutdownSend();
|
||||
closesocket(soc);
|
||||
WSACleanup();
|
||||
soc = NULL;
|
||||
}
|
||||
catch (std::exception) { }
|
||||
}
|
||||
|
||||
WSADATA wsaData;
|
||||
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
|
||||
return false;
|
||||
|
||||
struct addrinfo *result = nullptr, hints;
|
||||
|
||||
if (socketType == VOID_CLIENT && protocolType == VOID_TCP)
|
||||
{
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
}
|
||||
else if (socketType == VOID_CLIENT && protocolType == VOID_UDP)
|
||||
{
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
}
|
||||
else if (socketType == VOID_SERVER && protocolType == VOID_TCP)
|
||||
{
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
}
|
||||
else if (socketType == VOID_SERVER && protocolType == VOID_UDP)
|
||||
{
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
}
|
||||
|
||||
if (socketType == VOID_CLIENT)
|
||||
{
|
||||
if (getaddrinfo(ipAddr.c_str(), (PCSTR)port, &hints, &result) == SOCKET_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getaddrinfo(nullptr, (PCSTR)port, &hints, &result) == SOCKET_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto Socket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
|
||||
|
||||
if (Socket == INVALID_SOCKET)
|
||||
{
|
||||
freeaddrinfo(result);
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
addrInfo = result;
|
||||
soc = Socket;
|
||||
return true;
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <WS2tcpip.h>
|
||||
#include <string>
|
||||
|
||||
namespace VoidNet
|
||||
{
|
||||
struct Socket
|
||||
{
|
||||
Socket(int, int);
|
||||
Socket(std::string, unsigned int, int, int);
|
||||
~Socket();
|
||||
bool operator == (Socket&);
|
||||
bool operator != (Socket&);
|
||||
unsigned int getPortNumber();
|
||||
std::string getIPAddress();
|
||||
std::string getPeerAddress();
|
||||
bool connectToHost();
|
||||
bool sendBytes(const char*, int);
|
||||
bool receiveBytes(char*, int);
|
||||
bool shutdownReceive();
|
||||
bool shutdownSend();
|
||||
bool dataAvailable(int&);
|
||||
bool dataAvailable();
|
||||
bool setBlocking(bool);
|
||||
private:
|
||||
SOCKET soc;
|
||||
struct addrinfo *addrInfo;
|
||||
std::string ipAddr;
|
||||
unsigned int port;
|
||||
int socketType;
|
||||
int protocolType;
|
||||
bool init(int, int);
|
||||
};
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
#include "TCPConnection.h"
|
||||
@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
namespace VoidNet
|
||||
{
|
||||
struct TCPConnection
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
#include "TCPServer.h"
|
||||
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct TCPServer
|
||||
{
|
||||
|
||||
};
|
||||
@ -1 +0,0 @@
|
||||
#pragma once
|
||||
@ -1 +0,0 @@
|
||||
#pragma once
|
||||
Reference in New Issue
Block a user