diff --git a/include/Makefile.am b/include/Makefile.am index f75bf54..a0d88a9 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -6,6 +6,7 @@ nobase_include_HEADERS = trcomm.h \ tr/connection.h \ tr/connector.h \ tr/datagram_service.h \ + tr/datagram_entry_point.h \ tr/io_handler.h \ tr/proto_message.h \ tr/protocol.h \ diff --git a/src/con_compose.c b/include/tr/datagram_entry_point.h similarity index 64% rename from src/con_compose.c rename to include/tr/datagram_entry_point.h index d05e417..ecdc807 100644 --- a/src/con_compose.c +++ b/include/tr/datagram_entry_point.h @@ -20,5 +20,26 @@ * along with this program. If not, see . */ +#ifndef __TR_DATAGRAM_ENTRY_POINT_H__ +#define __TR_DATAGRAM_ENTRY_POINT_H__ + +#include + +#include "trbase.h" +#include "trevent.h" +#include "trdata.h" + +#include "tr/comm_end_point.h" + +TR_CLASS(TR_DatagramEntryPoint) { + TR_EXTENDS(TR_DatagramService); +}; +TR_INSTANCE_INIT(TR_DatagramEntryPoint); +TR_CLASSVARS_DECL(TR_DatagramEntryPoint) { + TR_CV_EXTENDS(TR_CommEndPoint); +}; + +#endif // __TR_DATAGRAM_ENTRY_POINT_H__ // vim: set ts=4 sw=4: + diff --git a/include/trcomm.h b/include/trcomm.h index bbade86..26b72aa 100644 --- a/include/trcomm.h +++ b/include/trcomm.h @@ -8,6 +8,7 @@ #include "tr/connection.h" #include "tr/connector.h" #include "tr/datagram_service.h" +#include "tr/datagram_entry_point.h" #include "tr/io_handler.h" #include "tr/proto_message.h" #include "tr/protocol.h" diff --git a/src/Makefile.am b/src/Makefile.am index f2cc430..12b73e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,12 +12,11 @@ TRCOMM = cep_append_read_data.c \ comm_manager.c \ comm_manager_poll.c \ comm_manager_shutdown.c \ - con_compose.c \ - con_next_message.c \ conn_entry_point.c \ connection.c \ connector.c \ datagram_service.c \ + datagram_entry_point.c \ io_handler.c \ proto_message.c \ protocol.c \ diff --git a/src/con_next_message.c b/src/con_next_message.c deleted file mode 100644 index d05e417..0000000 --- a/src/con_next_message.c +++ /dev/null @@ -1,24 +0,0 @@ -/** - * \file - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2014 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -// vim: set ts=4 sw=4: diff --git a/src/datagram_entry_point.c b/src/datagram_entry_point.c new file mode 100644 index 0000000..4eda275 --- /dev/null +++ b/src/datagram_entry_point.c @@ -0,0 +1,64 @@ +/** + * \file + * + * \author Georg Hopp + * + * \copyright + * Copyright © 2014 Georg Hopp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "trbase.h" + +#include "tr/datagram_service.h" +#include "tr/datagram_entry_point.h" + +static +int +datagramEntryPointCtor(void * _this, va_list * params) +{ + TR_CommEndPoint this = _this; + + TR_PARENTCALL(TR_DatagramEntryPoint, _this, TR_Class, ctor, params); + + TR_socketBind((TR_Socket)this->transport); + TR_socketNonblock((TR_Socket)this->transport); + + return 0; +} + +static +void +datagramEntryPointDtor(void * _this) +{ + TR_PARENTCALL(TR_DatagramEntryPoint, _this, TR_Class, dtor); +} + +intptr_t datagramEntryPoint_events[TR_CEP_EVENT_MAX + 1]; +TR_INIT_IFACE(TR_Class, datagramEntryPointCtor, datagramEntryPointDtor, NULL); +TR_CREATE_CLASS( + TR_DatagramEntryPoint, + TR_DatagramService, + NULL, + TR_IF(TR_Class)) = { + {{ + TR_CEP_EVENT_MAX + 1, + datagramEntryPoint_events + }} +}; + +// vim: set ts=4 sw=4: diff --git a/testers/testserver2.c b/testers/testserver2.c index 9f641d6..11f9072 100644 --- a/testers/testserver2.c +++ b/testers/testserver2.c @@ -28,11 +28,9 @@ main (int argc, char * argv[]) TR_new(TR_ConnEntryPoint, socket, protocol)); socket = TR_new(TR_UdpSocket, TR_logger, "0.0.0.0", 5678, 0); - TR_socketBind((TR_Socket)socket); - TR_socketNonblock((TR_Socket)socket); TR_serverAddEndpoint( server, - TR_new(TR_DatagramService, socket, protocol)); + TR_new(TR_DatagramEntryPoint, socket, protocol)); TR_serverStart(server, 1000);