Browse Source

add datagram entry point class

1.0.0
Georg Hopp 12 years ago
parent
commit
f3ee0d7e02
  1. 1
      include/Makefile.am
  2. 21
      include/tr/datagram_entry_point.h
  3. 1
      include/trcomm.h
  4. 3
      src/Makefile.am
  5. 24
      src/con_next_message.c
  6. 64
      src/datagram_entry_point.c
  7. 4
      testers/testserver2.c

1
include/Makefile.am

@ -6,6 +6,7 @@ nobase_include_HEADERS = trcomm.h \
tr/connection.h \ tr/connection.h \
tr/connector.h \ tr/connector.h \
tr/datagram_service.h \ tr/datagram_service.h \
tr/datagram_entry_point.h \
tr/io_handler.h \ tr/io_handler.h \
tr/proto_message.h \ tr/proto_message.h \
tr/protocol.h \ tr/protocol.h \

21
src/con_compose.c → include/tr/datagram_entry_point.h

@ -20,5 +20,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __TR_DATAGRAM_ENTRY_POINT_H__
#define __TR_DATAGRAM_ENTRY_POINT_H__
#include <sys/types.h>
#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: // vim: set ts=4 sw=4:

1
include/trcomm.h

@ -8,6 +8,7 @@
#include "tr/connection.h" #include "tr/connection.h"
#include "tr/connector.h" #include "tr/connector.h"
#include "tr/datagram_service.h" #include "tr/datagram_service.h"
#include "tr/datagram_entry_point.h"
#include "tr/io_handler.h" #include "tr/io_handler.h"
#include "tr/proto_message.h" #include "tr/proto_message.h"
#include "tr/protocol.h" #include "tr/protocol.h"

3
src/Makefile.am

@ -12,12 +12,11 @@ TRCOMM = cep_append_read_data.c \
comm_manager.c \ comm_manager.c \
comm_manager_poll.c \ comm_manager_poll.c \
comm_manager_shutdown.c \ comm_manager_shutdown.c \
con_compose.c \
con_next_message.c \
conn_entry_point.c \ conn_entry_point.c \
connection.c \ connection.c \
connector.c \ connector.c \
datagram_service.c \ datagram_service.c \
datagram_entry_point.c \
io_handler.c \ io_handler.c \
proto_message.c \ proto_message.c \
protocol.c \ protocol.c \

24
src/con_next_message.c

@ -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 <http://www.gnu.org/licenses/>.
*/
// vim: set ts=4 sw=4:

64
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 <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#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:

4
testers/testserver2.c

@ -28,11 +28,9 @@ main (int argc, char * argv[])
TR_new(TR_ConnEntryPoint, socket, protocol)); TR_new(TR_ConnEntryPoint, socket, protocol));
socket = TR_new(TR_UdpSocket, TR_logger, "0.0.0.0", 5678, 0); 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( TR_serverAddEndpoint(
server, server,
TR_new(TR_DatagramService, socket, protocol));
TR_new(TR_DatagramEntryPoint, socket, protocol));
TR_serverStart(server, 1000); TR_serverStart(server, 1000);

Loading…
Cancel
Save