Commit 053a9941 authored by jan.koester's avatar jan.koester
Browse files

Merge branch 'main' of git.tuxist.de:jan.koester/libnetplus

parents 3f22965f dd1979b1
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -36,21 +36,29 @@ include_directories(

add_library(netplus SHARED ${netplussrc})

target_link_libraries(netplus) #PUBLIC MbedTLS::mbedcrypto MbedTLS::mbedtls MbedTLS::mbedx509)
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Windows")
   target_link_libraries(netplus)
else()
   target_link_libraries(netplus pthread) #PUBLIC MbedTLS::mbedcrypto MbedTLS::mbedtls MbedTLS::mbedx509)
endif()

set_property(TARGET netplus PROPERTY VERSION ${Upstream_VERSION})
set_property(TARGET netplus PROPERTY SOVERSION ${LIBV})
set_property(TARGET netplus PROPERTY INTERFACE_systempp_MAJOR_VERSION ${LIBV})
set_property(TARGET netplus APPEND PROPERTY COMPATIBLE_INTERFACE_STRING cryptplus_MAJOR_VERSION)

install(TARGETS netplus DESTINATION lib EXPORT netplusTargets)
install(TARGETS netplus EXPORT netplusTargets 
	DESTINATION lib 
	INCLUDES DESTINATION include
)

install(FILES
    socket.h
    exception.h
    eventapi.h
    connection.h
DESTINATION include/netplus)
DESTINATION include/netplus
)

set(ConfigPackageLocation lib/cmake/libnetplus)

+6 −10
Original line number Diff line number Diff line
@@ -164,11 +164,9 @@ namespace netplus {
        void ConnectEventHandler(int pos,const int tid,void *args)  {
            NetException exception;
            con *ccon=(con*)_Events[pos].data.ptr;
            if(ccon){
                CloseEventHandler(pos,tid,args);
            }

            _evtapi->CreateConnetion(&ccon);

            if(_ServerSocket->_Type==sockettype::TCP){
                ccon->csock=new tcp();
            }else if(_ServerSocket->_Type==sockettype::UDP){
@@ -298,7 +296,6 @@ namespace netplus {

                _evtapi->deleteConnetion(ccon);

                _Events[pos].data.ptr=nullptr;
            }catch(NetException &e){
                throw e;
            }
@@ -349,17 +346,16 @@ EVENTLOOP:
                        switch (pollptr.pollState(i)) {
                            case pollapi::EventHandlerStatus::EVCON:
                                pollptr.ConnectEventHandler(i,tid,args);
                                break;
                                continue;
                            case pollapi::EventHandlerStatus::EVIN:
                                pollptr.ReadEventHandler(i,tid,args);
                                break;
                                continue;
                            case pollapi::EventHandlerStatus::EVOUT:
                                pollptr.WriteEventHandler(i,tid,args);
                                break;
                                continue;
                            default:
                                NetException  e;
                                e[NetException::Error] << "EventWorker: Request type not kwon!";
                                pollptr.CloseEventHandler(i,tid,args);
                                throw e;
                        }
                    }catch(NetException& e){
@@ -367,11 +363,11 @@ EVENTLOOP:
                            case NetException::Critical:
                                throw e;
                            case NetException::Note:
                                break;
                                continue;
                            default:
                                std::cerr << e.what() << std::endl;
                                pollptr.CloseEventHandler(i,tid,args);
                                break;
                                continue;
                        }
                    }
                }
+10 −13
Original line number Diff line number Diff line
@@ -157,10 +157,7 @@ namespace netplus {

        void ConnectEventHandler(int pos,const int tid,void *args)  {
            NetException exception;
            con *ccon=(con*)_Events[pos].udata;
            if(ccon){
                CloseEventHandler(pos,tid,args);
            }
            con *ccon;

            _evtapi->CreateConnetion(&ccon);

@@ -280,7 +277,7 @@ namespace netplus {
            try{
                struct kevent setevent { 0 };

                EV_SET(&setevent,ccon->csock->fd(),0,EV_CLEAR,0,0,nullptr);
                EV_SET(&setevent,ccon->csock->fd(),0, EV_DELETE,0,0,nullptr);

                if(kevent(_pollFD,&setevent,1,nullptr,0,nullptr)<0){
                    NetException except;
@@ -289,13 +286,13 @@ namespace netplus {
                    except[NetException::Error] << "CloseEventHandler: can't close socket to kqueue: " << errstr;
                    throw except;
                }

                delete  ccon->csock;

                _evtapi->DisconnectEvent(ccon,tid,args);

                _evtapi->deleteConnetion(ccon);

                _Events[pos].udata=nullptr;
            }catch(NetException &e){
                throw e;
            }
@@ -346,13 +343,13 @@ EVENTLOOP:
                        switch (pollptr.pollState(i)) {
                            case pollapi::EventHandlerStatus::EVCON:
                                pollptr.ConnectEventHandler(i,tid,args);
                                break;
                                continue;
                            case pollapi::EventHandlerStatus::EVIN:
                                pollptr.ReadEventHandler(i,tid,args);
                                break;
                                continue;
                            case pollapi::EventHandlerStatus::EVOUT:
                                pollptr.WriteEventHandler(i,tid,args);
                                break;
                                continue;
                            default:
                                NetException  e;
                                e[NetException::Error] << "EventWorker: no known event !";
@@ -363,11 +360,11 @@ EVENTLOOP:
                            case NetException::Critical:
                                throw e;
                            case NetException::Note:
                                break;
                                continue;
                            default:
                                std::cerr << e.what() << std::endl;
                                pollptr.CloseEventHandler(i,tid,args);
                                break;
                                continue;
                        }
                    }
                }
@@ -442,7 +439,7 @@ EVENTLOOP:
            0
        };

        EV_SET(&setevent,_ServerSocket->fd(),EVFILT_READ,EV_ADD | EV_CLEAR | EV_ONESHOT,0,0,nullptr);
        EV_SET(&setevent,_ServerSocket->fd(),EVFILT_READ,EV_ADD | EV_CLEAR,0,0,nullptr);

        if (kevent(_pollFD,&setevent,1,nullptr,0,nullptr) < 0) {
            char errstr[255];
+23 −24
Original line number Diff line number Diff line
/*******************************************************************************
Copyright (c) 2014, Jan Koester jan.koester@gmx.net
 C *opyright (c) 2014, Jan Koester jan.koester@gmx.net
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
@@ -65,4 +65,3 @@ void netplus::socket::setnonblocking(){
        throw exception;
    }
}
+8 −8
Original line number Diff line number Diff line
@@ -196,11 +196,11 @@ void netplus::tcp::bind(){
}


unsigned int netplus::tcp::sendData(socket *csock, void* data, unsigned long size){
size_t netplus::tcp::sendData(socket *csock, void* data, unsigned long size){
    return sendData(csock,data,size,0);
}

unsigned int netplus::tcp::sendData(socket *csock, void* data, unsigned long size,int flags){
size_t netplus::tcp::sendData(socket *csock, void* data, unsigned long size,int flags){

    NetException exception;

@@ -208,8 +208,8 @@ unsigned int netplus::tcp::sendData(socket *csock, void* data, unsigned long siz
                        data,
                        size,
                        flags,
                        (struct sockaddr *)&csock->_SocketPtr,
                        csock->_SocketPtrSize
                        (struct sockaddr *)csock->_SocketPtr,
                        sizeof(struct sockaddr)
                     );
    if(rval<0){
        int etype=NetException::Error;
@@ -226,11 +226,11 @@ unsigned int netplus::tcp::sendData(socket *csock, void* data, unsigned long siz
}


unsigned int netplus::tcp::recvData(socket *csock, void* data, unsigned long size){
size_t netplus::tcp::recvData(socket *csock, void* data, unsigned long size){
    return recvData(csock,data,size,0);
}

unsigned int netplus::tcp::recvData(socket *csock, void* data, unsigned long size,int flags){
size_t netplus::tcp::recvData(socket *csock, void* data, unsigned long size,int flags){

    NetException exception;

@@ -238,8 +238,8 @@ unsigned int netplus::tcp::recvData(socket *csock, void* data, unsigned long siz
                            data,
                            size,
                            flags,
                            (struct sockaddr *)&csock->_SocketPtr,
                            &csock->_SocketPtrSize
                            (struct sockaddr *)csock->_SocketPtr,
                            (socklen_t*)&csock->_SocketPtrSize
                         );
    if(recvsize<0){
        int etype=NetException::Error;
Loading