00001 /* 00002 * Scale Stack 00003 * 00004 * Copyright 2010 Chris Behrens 00005 * 00006 * Licensed under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00024 #include "config.h" 00025 00026 #include <scalestack/echo/server/datagram.h> 00027 00028 namespace scalestack 00029 { 00030 namespace echo 00031 { 00032 namespace server 00033 { 00034 00035 /* 00036 * Public methods. 00037 */ 00038 00039 datagram::datagram(kernel::module& module): 00040 network::datagram(module), 00041 _size(), 00042 _buffer() 00043 { 00044 } 00045 00046 size_t datagram::receive(uint8_t* buffer, size_t size, struct sockaddr&, 00047 socklen_t) 00048 { 00049 _size = size; 00050 _buffer = buffer; 00051 return _echo(); 00052 } 00053 00054 void datagram::flush_send(void) 00055 { 00056 consume(_echo()); 00057 } 00058 00059 /* 00060 * Private methods. 00061 */ 00062 00063 size_t datagram::_echo(void) 00064 { 00065 return send(_buffer, _size); 00066 } 00067 00068 } /* namespace server */ 00069 } /* namespace echo */ 00070 } /* namespace scalestack */
1.6.3