Commit 36e2aec5 authored by jan.koester's avatar jan.koester
Browse files

test

parent 565a6a04
Loading
Loading
Loading
Loading
+5 −5
Changes for src/posix/tcp.cpp: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -46,19 +46,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "socket.h"
#include "error.h"

netplus::tcp::tcp(const char* uxsocket,int maxconnections,int sockopts) : socket(){
netplus::tcp::tcp(const std::string &uxsocket,int maxconnections,int sockopts) : socket(){
    NetException exception;
    int optval = 1;
    if(sockopts == -1)
        sockopts=SO_REUSEADDR;
    _Maxconnections=maxconnections;
    ((struct sockaddr_un *)_SocketInfo)->sun_family = AF_UNIX;
    if(!uxsocket){
    if(uxsocket.empty()){
        exception[NetException::Critical] << "Can't copy Server UnixSocket";
        throw exception;
    }
    _UxPath=uxsocket;
    memcpy(((struct sockaddr_un *)_SocketInfo)->sun_path,uxsocket,strlen(uxsocket)+1);
    memcpy(((struct sockaddr_un *)_SocketInfo)->sun_path,uxsocket.c_str(),uxsocket.length()+1);

    if ((_Socket=::socket(AF_UNIX,SOCK_STREAM, 0)) < 0){
        exception[NetException::Critical] << "Can't create TCP UnixSocket";
@@ -69,7 +69,7 @@ netplus::tcp::tcp(const char* uxsocket,int maxconnections,int sockopts) : socket
    _Type=sockettype::TCP;
}

netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) : socket() {
netplus::tcp::tcp(const std::string &addr, int port,int maxconnections,int sockopts) : socket() {
    NetException exception;
    _Maxconnections=maxconnections;
    if(sockopts == -1)
@@ -93,7 +93,7 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) :
    char serv[512];
    snprintf(serv,512,"%d",port);

    if ((tsock=::getaddrinfo(addr, serv,&hints,&result)) < 0) {
    if ((tsock=::getaddrinfo(addr.c_str(), serv,&hints,&result)) < 0) {
        exception[NetException::Critical] << "Socket Invalid address/ Address not supported";
        throw exception;
    }
+6 −6
Changes for src/posix/udp.cpp: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -46,19 +46,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "socket.h"
#include "error.h"

netplus::udp::udp(const char* uxsocket,int maxconnections,int sockopts) : socket(){
netplus::udp::udp(const std::string &uxsocket,int maxconnections,int sockopts) : socket(){
    NetException exception;
    int optval = 1;
    if(sockopts == -1)
        sockopts=SO_REUSEADDR;
    _Maxconnections=maxconnections;
    ((struct sockaddr_un *)_SocketInfo)->sun_family = AF_UNIX;
    if(!uxsocket){
    if(uxsocket.empty()){
        exception[NetException::Critical] << "Can't copy Server UnixSocket";
        throw exception;
    }
    _UxPath=uxsocket;
    memcpy(((struct sockaddr_un *)_SocketInfo)->sun_path,uxsocket,strlen(uxsocket)+1);
    memcpy(((struct sockaddr_un *)_SocketInfo)->sun_path,uxsocket.c_str(),uxsocket.length()+1);

    if ((_Socket=::socket(AF_UNIX,SOCK_DGRAM, 0)) < 0){
        exception[NetException::Critical] << "Can't create UDP UnixSocket";
@@ -69,7 +69,7 @@ netplus::udp::udp(const char* uxsocket,int maxconnections,int sockopts) : socket
    _Type=sockettype::UDP;
}

netplus::udp::udp(const char* addr, int port,int maxconnections,int sockopts) : socket() {
netplus::udp::udp(const std::string &addr, int port,int maxconnections,int sockopts) : socket() {
    NetException exception;
    _Maxconnections=maxconnections;
    if(sockopts == -1)
@@ -93,7 +93,7 @@ netplus::udp::udp(const char* addr, int port,int maxconnections,int sockopts) :
    char serv[512];
    snprintf(serv,512,"%d",port);

    if ((tsock=::getaddrinfo(addr, serv,&hints,&result)) < 0) {
    if ((tsock=::getaddrinfo(addr.c_str(), serv,&hints,&result)) < 0) {
        exception[NetException::Critical] << "Socket Invalid address/ Address not supported";
        throw exception;
    }
@@ -153,7 +153,7 @@ int netplus::udp::getMaxconnections(){
    return _Maxconnections;
}

void netplus::udp::accept(socket *csock){
void netplus::udp::accept(std::shared_ptr<socket> &csock){
    NetException exception;

    ((struct addrinfo *)(csock->_SocketInfo))->ai_addr=(struct sockaddr*) malloc(((struct addrinfo *)(_SocketInfo))->ai_addrlen);
+6 −6
Changes for src/socket.h: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -94,9 +94,9 @@ namespace netplus {
            tcp();
            tcp(SOCKET socket);
            tcp(const netplus::tcp& ctcp) = delete;
            tcp(const char *uxsocket,int maxconnections,
            tcp(const std::string &uxsocket,int maxconnections,
                int sockopts);
            tcp(const char *addr,int port,int maxconnections,
            tcp(const std::string &addr,int port,int maxconnections,
                int sockopts);
            ~tcp();
#ifdef Windows 
@@ -126,9 +126,9 @@ namespace netplus {
            udp();
            udp(SOCKET sock);
            udp(const udp &cudp) = delete;
            udp(const char *uxsocket,int maxconnections,
            udp(const std::string &uxsocket,int maxconnections,
                int sockopts);
            udp(const char *addr,int port,int maxconnections,
            udp(const std::string &addr,int port,int maxconnections,
                int sockopts);
            ~udp();

@@ -160,9 +160,9 @@ namespace netplus {
        public:
            ssl();
            /*client socket*/
            ssl(const char *addr,int port,int maxconnections,int sockopts,const unsigned char *ca,size_t calen);
            ssl(const std::string &addr,int port,int maxconnections,int sockopts,const unsigned char *ca,size_t calen);
            /*server socket*/
            ssl(const char *addr,int port,int maxconnections,
            ssl(const std::string &addr,int port,int maxconnections,
                int sockopts,const unsigned char *cert,size_t certlen,const unsigned char *key, size_t keylen);
            ~ssl();
            
+4 −4
Changes for src/ssl.cpp: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -11,11 +11,11 @@ namespace netplus {
};


netplus::ssl::ssl(const char *addr,int port,int maxconnections,int sockopts,const unsigned char *ca,size_t calen) : ssl() {
netplus::ssl::ssl(const std::string &addr,int port,int maxconnections,int sockopts,const unsigned char *ca,size_t calen) : ssl() {

}

netplus::ssl::ssl(const char *addr,int port,int maxconnections,int sockopts,const unsigned char *cert,
netplus::ssl::ssl(const std::string &addr,int port,int maxconnections,int sockopts,const unsigned char *cert,
    size_t certlen, const unsigned char* key, size_t keylen) : ssl() {
    _Port=port;
    _Type=sockettype::SSL;
@@ -39,12 +39,12 @@ int netplus::ssl::getMaxconnections(){
    return _Maxconnections;
}

size_t netplus::ssl::sendData(void *data,unsigned long size, int flags){
size_t netplus::ssl::sendData(std::shared_ptr<char> &data,size_t size, int flags){
    NetException exception;
    return 0;
}

size_t netplus::ssl::recvData(void *data,unsigned long size,int flags){
size_t netplus::ssl::recvData(std::shared_ptr<char> &data,size_t size,int flags){
    return 0;
}

+3 −3
Changes for src/windows/tcp.cpp: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -42,13 +42,13 @@ extern "C" {
#include "exception.h"
#include "socket.h"

netplus::tcp::tcp(const char* uxsocket,int maxconnections,int sockopts) : socket() {
netplus::tcp::tcp(const std::string &uxsocket,int maxconnections,int sockopts) : socket() {
    NetException exception;
    exception[NetException::Critical] << "tcp: Windows doesn't support UnixSockets !";
    throw exception;
}

netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) : socket() {
netplus::tcp::tcp(const std::string &addr, int port,int maxconnections,int sockopts) : socket() {
    NetException exception;
    _Maxconnections=maxconnections;

@@ -71,7 +71,7 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) :
    char serv[512];
    snprintf(serv,512,"%d",port);

    if ((tsock=::getaddrinfo(addr, serv,&hints,&result)) < 0) {
    if ((tsock=::getaddrinfo(addr.c_str(), serv,&hints,&result)) < 0) {
        exception[NetException::Critical] << "Socket Invalid address/ Address not supported";
        throw exception;
    }