⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inetprot.h

📁 pwlib源码库
💻 H
📖 第 1 页 / 共 2 页
字号:
       TRUE if the string and CR/LF were completely written.     */    virtual BOOL WriteLine(      const PString & line // String to write as a command line.    );    /** Read a string from the socket channel up to a CR/LF pair.           If the <CODE>unstuffLine</CODE> parameter is set then the function will       remove the '.' character from the start of any line that begins with       two consecutive '.' characters. A line that has is exclusively a '.'       character will make the function return FALSE.       Note this function will block for the time specified by the       <A>PChannel::SetReadTimeout()</A> function for only the first character       in the line. The rest of the characters must each arrive within the time       set by the <CODE>readLineTimeout</CODE> member variable. The timeout is       set back to the original setting when the function returns.       @return       TRUE if a CR/LF pair was received, FALSE if a timeout or error occurred.     */    virtual BOOL ReadLine(      PString & line,             // String to receive a CR/LF terminated line.      BOOL allowContinuation = FALSE  // Flag to handle continued lines.    );    /** Put back the characters into the data stream so that the next       <A>Read()</A> function call will return them first.     */    virtual void UnRead(      int ch                // Individual character to be returned.    );    virtual void UnRead(      const PString & str   // String to be put back into data stream.    );    virtual void UnRead(      const void * buffer,  // Characters to be put back into data stream.      PINDEX len            // Number of characters to be returned.    );    /** Write a single line for a command. The command name for the command       number is output, then a space, the the <CODE>param</CODE> string       followed at the end with a CR/LF pair.       If the <CODE>cmdNumber</CODE> parameter is outside of the range of       valid command names, then the function does not send anything and       returns FALSE.       This function is typically used by client forms of the socket.       @return       TRUE if the command was completely written.     */    virtual BOOL WriteCommand(      PINDEX cmdNumber       // Number of command to write.    );    virtual BOOL WriteCommand(      PINDEX cmdNumber,      // Number of command to write.      const PString & param  // Extra parameters required by the command.    );    /** Read a single line of a command which ends with a CR/LF pair. The       command number for the command name is parsed from the input, then the       remaining text on the line is returned in the <CODE>args</CODE>       parameter.       If the command does not match any of the command names then the entire       line is placed in the <CODE>args</CODE> parameter and a value of       P_MAX_INDEX is returned.       Note this function will block for the time specified by the       <A>PChannel::SetReadTimeout()</A> function.       This function is typically used by server forms of the socket.       @return       TRUE if something was read, otherwise an I/O error occurred.     */    virtual BOOL ReadCommand(      PINDEX & num,       // Number of the command parsed from the command line, or P_MAX_INDEX       // if no match.      PString & args  // String to receive the arguments to the command.    );    /** Write a response code followed by a text string describing the response       to a command. The form of the response is to place the code string,       then the info string.              If the <CODE>info</CODE> parameter has multiple lines then each line       has the response code at the start. A '-' character separates the code       from the text on all lines but the last where a ' ' character is used.       The first form assumes that the response code is a 3 digit numerical       code. The second form allows for any arbitrary string to be the code.       This function is typically used by server forms of the socket.       @return       TRUE if the response was completely written.     */    virtual BOOL WriteResponse(      unsigned numericCode, // Response code for command response.      const PString & info  // Extra information available after response code.    );    virtual BOOL WriteResponse(      const PString & code, // Response code for command response.      const PString & info  // Extra information available after response code.    );    /** Read a response code followed by a text string describing the response       to a command. The form of the response is to have the code string,       then the info string.              The response may have multiple lines in it. A '-' character separates       the code from the text on all lines but the last where a ' ' character       is used. The <CODE>info</CODE> parameter will have placed in it all of       the response lines separated by a single '\n' character.       The first form places the response code and info into the protected       member variables <CODE>lastResponseCode</CODE> and       <CODE>lastResponseInfo</CODE>.       This function is typically used by client forms of the socket.       @return       TRUE if the response was completely read without a socket error.     */    virtual BOOL ReadResponse();    virtual BOOL ReadResponse(      int & code,      // Response code for command response.      PString & info   // Extra information available after response code.    );    /** Write a command to the socket, using <CODE>WriteCommand()</CODE> and       await a response using <CODE>ReadResponse()</CODE>. The first character       of the response is returned, as well as the entire response being saved       into the protected member variables <CODE>lastResponseCode</CODE> and       <CODE>lastResponseInfo</CODE>.       This function is typically used by client forms of the socket.       @return       First character of response string or '\0' if a socket error occurred.     */    virtual int ExecuteCommand(      PINDEX cmdNumber       // Number of command to write.    );    virtual int ExecuteCommand(      PINDEX cmdNumber,      // Number of command to write.      const PString & param  // Extra parameters required by the command.    );    /** Return the code associated with the last response received by the       socket.       @return       Response code    */    int GetLastResponseCode() const;    /** Return the last response received by the socket.       @return       Response as a string    */    PString GetLastResponseInfo() const;  protected:    /** Parse a response line string into a response code and any extra info       on the line. Results are placed into the member variables       <CODE>lastResponseCode</CODE> and <CODE>lastResponseInfo</CODE>.       The default bahaviour looks for a space or a '-' and splits the code       and info either side of that character, then returns FALSE.       @return       Position of continuation character in response, 0 if no continuation       lines are possible.     */    virtual PINDEX ParseResponse(      const PString & line // Input response line to be parsed    );    PString defaultServiceName;    // Default Service name to use for the internet protocol socket.    PStringArray commandNames;    // Names of each of the command codes.    PCharArray unReadBuffer;    // Buffer for characters put back into the data stream.    PINDEX unReadCount;    // Buffer count for characters put back into the data stream.    PTimeInterval readLineTimeout;    // Time for characters in a line to be received.    enum StuffState {      DontStuff, StuffIdle, StuffCR, StuffCRLF, StuffCRLFdot, StuffCRLFdotCR    } stuffingState;    // Do byte stuffing of '.' characters in output to the socket channel.    BOOL newLineToCRLF;    // Translate \n characters to CR/LF pairs.    int     lastResponseCode;    PString lastResponseInfo;    // Responses  private:    BOOL AttachSocket(PIPSocket * socket);};#endif// End Of File ///////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -