Back to index

lightning-sunbird  0.9+nobinonly
rcnetio.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039 ** Subclass definitions for network I/O (ref: prio.h)
00040 */
00041 
00042 #if defined(_RCNETIO_H)
00043 #else
00044 #define _RCNETIO_H
00045 
00046 #include "rcbase.h"
00047 #include "rcinrval.h"
00048 #include "rcio.h"
00049 #include "rcnetdb.h"
00050 
00051 #include "prio.h"
00052 
00053 class RCFileInfo;
00054 
00055 /*
00056 ** Class: RCNetStreamIO (ref prio.h)
00057 **
00058 ** Streamed (reliable) network I/O (e.g., TCP).
00059 ** This class hides (makes private) the functions that are not applicable
00060 ** to network I/O (i.e., those for file I/O).
00061 */
00062 
00063 class PR_IMPLEMENT(RCNetStreamIO): public RCIO
00064 {
00065 
00066 public:
00067     RCNetStreamIO();
00068     virtual ~RCNetStreamIO();
00069 
00070     virtual RCIO*       Accept(RCNetAddr* addr, const RCInterval& timeout);
00071     virtual PRInt32     AcceptRead(
00072                             RCIO **nd, RCNetAddr **raddr, void *buf,
00073                             PRSize amount, const RCInterval& timeout);
00074     virtual PRInt64     Available();
00075     virtual PRStatus    Bind(const RCNetAddr& addr);
00076     virtual PRStatus    Connect(
00077                             const RCNetAddr& addr, const RCInterval& timeout);
00078     virtual PRStatus    GetLocalName(RCNetAddr *addr) const;
00079     virtual PRStatus    GetPeerName(RCNetAddr *addr) const;
00080     virtual PRStatus    GetSocketOption(PRSocketOptionData *data) const;
00081     virtual PRStatus    Listen(PRIntn backlog);
00082     virtual PRInt16     Poll(PRInt16 in_flags, PRInt16 *out_flags);
00083     virtual PRInt32     Read(void *buf, PRSize amount);
00084     virtual PRInt32     Recv(
00085                             void *buf, PRSize amount, PRIntn flags,
00086                             const RCInterval& timeout);
00087     virtual PRInt32     Recvfrom(
00088                             void *buf, PRSize amount, PRIntn flags,
00089                             RCNetAddr* addr, const RCInterval& timeout);
00090     virtual PRInt32     Send(
00091                             const void *buf, PRSize amount, PRIntn flags,
00092                             const RCInterval& timeout);
00093     virtual PRInt32     Sendto(
00094                             const void *buf, PRSize amount, PRIntn flags,
00095                             const RCNetAddr& addr,
00096                             const RCInterval& timeout);
00097     virtual PRStatus    SetSocketOption(const PRSocketOptionData *data);
00098     virtual PRStatus    Shutdown(ShutdownHow how);
00099     virtual PRInt32     TransmitFile(
00100                             RCIO *source, const void *headers,
00101                             PRSize hlen, RCIO::FileDisposition flags,
00102                             const RCInterval& timeout);
00103     virtual PRInt32     Write(const void *buf, PRSize amount);
00104     virtual PRInt32     Writev(
00105                             const PRIOVec *iov, PRSize size,
00106                             const RCInterval& timeout);
00107 
00108 private:
00109     /* functions unavailable to this clients of this class */
00110     RCNetStreamIO(const RCNetStreamIO&);
00111 
00112     PRStatus    Close();
00113     PRStatus    Open(const char *name, PRIntn flags, PRIntn mode);
00114     PRStatus    FileInfo(RCFileInfo *info) const;
00115     PRStatus    Fsync();
00116     PRInt64     Seek(PRInt64 offset, RCIO::Whence how);
00117 
00118 public:
00119     RCNetStreamIO(PRIntn protocol);
00120 };  /* RCNetIO */
00121 
00122 #endif /* defined(_RCNETIO_H) */
00123 
00124 /* RCNetStreamIO.h */
00125 
00126