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

I_UDPNet.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 /****************************************************************************
00025 
00026   I_UDPNet.h
00027   This file provides UDP interface. To be included in I_Net.h
00028 
00029 
00030  ****************************************************************************/
00031 
00032 #ifndef __UDPNET_H_
00033 #define __UDPNET_H_
00034 
00035 #include "I_Version.h"
00036 #include "I_EventSystem.h"
00037 #include "ink_inet.h"
00038 
00039 /**
00040    UDP service
00041 
00042    You can create UDPConnections for asynchronous send/receive or call
00043    directly (inefficiently) into network layer.
00044  */
00045 class UDPNetProcessor:public Processor
00046 {
00047 public:
00048   virtual int start(int n_upd_threads, size_t stacksize) = 0;
00049 
00050   //this function was interanal intially.. this is required for public and
00051   //interface probably should change.
00052   bool CreateUDPSocket(int *resfd, sockaddr const* remote_addr, sockaddr* local_addr, int* local_addr_len,
00053                        Action ** status, int send_bufsize = 0, int recv_bufsize = 0);
00054 
00055   /**
00056      create UDPConnection
00057 
00058      Why was this implemented as an asynchronous call?  Just in case
00059      Windows requires it...
00060      <p>
00061      <b>Callbacks:</b><br>
00062      cont->handleEvent( NET_EVENT_DATAGRAM_OPEN, UDPConnection *) is
00063      called for new socket.
00064 
00065      @param c Continuation that is called back with newly created
00066      socket.
00067      @param addr Address to bind (includes port)
00068      @param send_bufsize (optional) Socket buffer size for sending.
00069      Limits how much outstanding data to OS before it is able to send
00070      to the NIC.
00071      @param recv_bufsize (optional) Socket buffer size for sending.
00072      Limits how much can be queued by OS before we read it.
00073      @return Action* Always returns ACTION_RESULT_DONE if socket was
00074      created successfuly, or ACTION_IO_ERROR if not.
00075   */
00076   inkcoreapi Action *UDPBind(Continuation * c, sockaddr const* addr, int send_bufsize = 0, int recv_bufsize = 0);
00077 
00078   // Regarding sendto_re, sendmsg_re, recvfrom_re:
00079   // * You may be called back on 'c' with completion or error status.
00080   // * 'token' is an opaque which can be used by caller to match up the I/O
00081   //   with the completion event.
00082   // * If IOBufferBlock * is passed in the interface, it is reference
00083   //   counted internally.
00084   // * For recvfrom_re, data is written beginning at IOBufferBlock::end() and
00085   //   the IOBufferBlock is not fill()'ed until I/O actually occurs.  This
00086   //   kind of implies that you can only have one outstanding I/O per
00087   //   IOBufferBlock
00088   // Callback:
00089   // * callback signature is: handleEvent(int event,CompletionEvent *cevent);
00090   //   where event is one of:
00091   //  NET_EVENT_DATAGRAM_WRITE_COMPLETE
00092   //  NET_EVENT_DATAGRAM_WRITE_ERROR
00093   // * You can get the value of 'token' that you passed in by calling
00094   //   completionUtil::getHandle(cevent);
00095   // * You can get other info about the completed operation through use
00096   //   of the completionUtil class.
00097   Action *sendto_re(Continuation * c, void *token, int fd,
00098                     sockaddr const* toaddr, int toaddrlen, IOBufferBlock * buf, int len);
00099   // I/O buffers referenced by msg must be pinned by the caller until
00100   // continuation is called back.
00101   Action *sendmsg_re(Continuation * c, void *token, int fd, struct msghdr *msg);
00102 
00103   Action *recvfrom_re(Continuation * c, void *token, int fd,
00104                       sockaddr *fromaddr, socklen_t *fromaddrlen,
00105                       IOBufferBlock * buf, int len, bool useReadCont = true, int timeout = 0);
00106 };
00107 
00108 inkcoreapi extern UDPNetProcessor & udpNet;
00109 
00110 #include "I_UDPPacket.h"
00111 #include "I_UDPConnection.h"
00112 
00113 #endif //__UDPNET_H_

Generated by  doxygen 1.7.1