• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

P_UDPIOEvent.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef _UDP_IO_EVENT_H_
00025 #define _UDP_IO_EVENT_H_
00026 // ugly -- just encapsulate the I/O result so that it can be passed
00027 // back to the caller via continuation handler.
00028 
00029 class UDPIOEvent:public Event
00030 {
00031 public:
00032   UDPIOEvent():fd(-1), err(0), m(0), handle(0), b(0), bytesTransferred(0)
00033   {
00034   };
00035   ~UDPIOEvent() {
00036   };
00037   void setInfo(int fd_, IOBufferBlock * b_, int bytesTransferred_, int errno_)
00038   {
00039     fd = fd_;
00040     b = b_;
00041     bytesTransferred = bytesTransferred_;
00042     err = errno_;
00043   };
00044   void setInfo(int fd_, struct msghdr *m_, int bytesTransferred_, int errno_)
00045   {
00046     fd = fd_;
00047     m = m_;
00048     bytesTransferred = bytesTransferred_;
00049     err = errno_;
00050   };
00051   void setHandle(void *v)
00052   {
00053     handle = v;
00054   }
00055   void *getHandle()
00056   {
00057     return handle;
00058   }
00059   void free();
00060   int getBytesTransferred()
00061   {
00062     return bytesTransferred;
00063   }
00064   IOBufferBlock *getIOBufferBlock()
00065   {
00066     return b;
00067   }
00068   int getError()
00069   {
00070     return err;
00071   }
00072   Continuation *getContinuation()
00073   {
00074     return continuation;
00075   }
00076   static void free(UDPIOEvent * e);
00077 private:
00078   void *operator  new(size_t size);     // undefined
00079   int fd;
00080   int err;                      // error code
00081   struct msghdr *m;
00082   void *handle;                 // some extra data for the client handler
00083   Ptr<IOBufferBlock> b;      // holds buffer that I/O will go to
00084   int bytesTransferred;         // actual bytes transferred
00085 };
00086 
00087 extern ClassAllocator<UDPIOEvent> UDPIOEventAllocator;
00088 TS_INLINE void
00089 UDPIOEvent::free(UDPIOEvent * e)
00090 {
00091   e->b = NULL;
00092   e->mutex = NULL;
00093   UDPIOEventAllocator.free(e);
00094 }
00095 #endif

Generated by  doxygen 1.7.1