# wxProtocol Class Reference
[Networking]

`#include <wx/protocol/protocol.h>`

Inheritance diagram for wxProtocol:
[legend]

## Detailed Description

Represents a protocol for use with wxURL.

Note that you may want to change the default time-out for HTTP/FTP connections and network operations (using SetDefaultTimeout()) since the default time-out value is quite long (60 seconds).

##

Library: wxNet

Category: Networking

See also:
  wxSocketBase, wxURL

## Public Member Functions
virtual bool | Abort ()=0
| Abort the current stream.
virtual wxString | GetContentType () const
| Returns the type of the content of the last opened stream.
virtual wxProtocolError | GetError () const
| Returns the last occurred error.
virtual wxInputStream * | GetInputStream (const wxString &path)=0
| Creates a new input stream on the specified path.
bool | Reconnect ()
| Tries to reestablish a previous opened connection (close and renegotiate connection).
virtual void | SetPassword (const wxString &user)
| Sets the authentication password.
virtual void | SetUser (const wxString &user)
| Sets the authentication user.
void | SetDefaultTimeout (wxUint32 Value)
| Sets a new default timeout for the network operations.
Logging support.
Each wxProtocol object may have the associated logger (by default there is none) which is used to log network requests and responses. See also: wxProtocolLog
void | SetLog (wxProtocolLog *log)
| Set the logger, deleting the old one and taking ownership of this one.
wxProtocolLog * | GetLog () const
| Return the current logger, may be NULL.
wxProtocolLog * | DetachLog ()
| Detach the existing logger without deleting it.
void | LogRequest (const wxString &str)
| Call wxProtocolLog::LogRequest() if we have a valid logger or do nothing otherwise.
void | LogResponse (const wxString &str)
| Call wxProtocolLog::LogResponse() if we have a valid logger or do nothing otherwise.

List of all members.

## Member Function Documentation

virtual bool wxProtocol::Abort | ( |  | ) | `[pure virtual]`

Abort the current stream.

Warning:
  It is advised to destroy the input stream instead of aborting the stream this way.

Returns:
  Returns true, if successful, else false.

Implemented in wxFTP.

wxProtocolLog* wxProtocol::DetachLog | ( |  | ) |

Detach the existing logger without deleting it.

The caller is responsible for deleting the returned pointer if it's non-`NULL`.

virtual wxString wxProtocol::GetContentType | ( |  | ) | const`[virtual]`

Returns the type of the content of the last opened stream.

It is a mime-type. May be an empty string if the content-type is unknown.

virtual wxProtocolError wxProtocol::GetError | ( |  | ) | const`[virtual]`

Returns the last occurred error.

See also:
  wxProtocolError

virtual wxInputStream* wxProtocol::GetInputStream | ( | const wxString & | path | ) | `[pure virtual]`

Creates a new input stream on the specified path.

You can use all but seek() functionality of wxStream. Seek() isn't available on all streams. For example, HTTP or FTP streams don't deal with it. Other functions like StreamSize() and Tell() aren't available for the moment for this sort of stream. You will be notified when the EOF is reached by an error.

Returns:
  Returns the initialized stream. You will have to delete it yourself once you don't use it anymore. The destructor closes the network connection.

See also:
  wxInputStream

Implemented in wxFTP, and wxHTTP.

wxProtocolLog* wxProtocol::GetLog | ( |  | ) | const`[inline]`

Return the current logger, may be NULL.

void wxProtocol::LogRequest | ( | const wxString & | str | ) |

Call wxProtocolLog::LogRequest() if we have a valid logger or do nothing otherwise.

void wxProtocol::LogResponse | ( | const wxString & | str | ) |

Call wxProtocolLog::LogResponse() if we have a valid logger or do nothing otherwise.

bool wxProtocol::Reconnect | ( |  | ) |

Tries to reestablish a previous opened connection (close and renegotiate connection).

Returns:
  true, if the connection is established, else false.

void wxProtocol::SetDefaultTimeout | ( | wxUint32 | Value | ) |

Sets a new default timeout for the network operations.

The default timeout is 60 seconds.

See also:
  wxSocketBase::SetTimeout

void wxProtocol::SetLog | ( | wxProtocolLog * | log | ) |

Set the logger, deleting the old one and taking ownership of this one.

Parameters:

  | log | New logger allocated on the heap or NULL.

virtual void wxProtocol::SetPassword | ( | const wxString & | user | ) | `[virtual]`

Sets the authentication password.

Reimplemented in wxFTP.

virtual void wxProtocol::SetUser | ( | const wxString & | user | ) | `[virtual]`

Sets the authentication user.

Reimplemented in wxFTP.

|  | [ top ]