30 #ifndef PTLIB_CHANNEL_H
31 #define PTLIB_CHANNEL_H
59 virtual int_type
overflow(int_type = EOF);
62 virtual pos_type
seekoff(std::streamoff, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out);
63 virtual pos_type
seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
179 FILE *
FDOpen(
const char * mode);
443 ) {
return Write(buf,len); }
486 #define PDECLARE_AsyncNotifier(cls, fn) PDECLARE_NOTIFIER2(PChannel, cls, fn, PChannel::AsyncContext &)
487 #define PCREATE_AsyncNotifier(fn) PCREATE_NOTIFIER2(fn, PChannel::AsyncContext &)
492 typedef OVERLAPPED AsyncContextBase;
494 typedef struct aiocb AsyncContextBase;
757 bool m_abortCommandString;
763 #include "msos/ptlib/channel.h"
765 #include "unix/ptlib/channel.h"
803 operator fd_set*()
const
820 #endif // PTLIB_CHANNEL_H
Operation fail due to insufficient privilege.
Definition: channel.h:232
virtual bool WriteAsync(AsyncContext &context)
Begin an asynchronous write from channel.
PString ReadString(PINDEX len)
Read len character into a string from the channel.
virtual PBoolean Shutdown(ShutdownValue option)
Close one or both of the data streams associated with a channel.
void AbortCommandString()
Abort a command string that is in progress.
Definition: channel.h:737
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the channel.
PTimeInterval readTimeout
Timeout for read operations.
Definition: channel.h:732
P_fd_set & operator-=(intptr_t fd)
Definition: channel.h:255
Open fail due to file already existing.
Definition: channel.h:230
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:51
No error.
Definition: channel.h:228
Array of characters.
Definition: array.h:552
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
Status()
Definition: channel.h:743
Operation failed due to a timeout.
Definition: channel.h:237
virtual int os_errno() const
Error during other operation, eg Open()
Definition: channel.h:254
virtual PChannel * GetBaseWriteChannel() const
Get the base channel of channel indirection using PIndirectChannel.
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the channel.
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
Errors m_errorCode
Error returned after operation completed.
Definition: channel.h:515
PTimeInterval writeTimeout
Timeout for write operations.
Definition: channel.h:733
PChannel & operator=(const PChannel &)
Definition: channel.h:591
PNotifierTemplate< PChannel::AsyncContext & > AsyncNotifier
Definition: channel.h:484
Operation fail due to bad parameters.
Definition: channel.h:234
PTimeInterval GetWriteTimeout() const
Get the timeout for write operations to complete.
virtual PINDEX HashFunction() const
Calculate a hash value for use in sets and dictionaries.
PBoolean WriteString(const PString &str)
Write a string to the channel.
Errors m_lastErrorCode
The platform independant error code.
Definition: channel.h:740
Definition: channel.h:498
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
FILE * FDOpen(const char *mode)
Re-open the device using the stdio library.
virtual PString GetName() const =0
Get the platform and I/O channel type name of the channel.
virtual void OnReadComplete(AsyncContext &context)
User callback function for when a ReadAsync() call has completed or timed out.
Definition: channel.h:590
PChannel()
Create the channel.
virtual PBoolean Write(const void *, PINDEX)
Low level write to the channel.
void SetOffset(off_t offset)
Set the offset to do the read/write operation.
virtual PINDEX GetLastWriteCount() const
Get the number of bytes written by the last Write() call.
Open fail due to device or file not found.
Definition: channel.h:229
PBoolean SetBufferSize(PINDEX newSize)
PBoolean ReceiveCommandString(int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
ShutdownValue
Definition: channel.h:589
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two strings.
Definition: channel.h:243
intptr_t max_fd
Definition: channel.h:811
virtual PINDEX SetLastWriteCount(PINDEX count)
PBoolean ReadBlock(void *buf, PINDEX len)
Read len bytes into the buffer from the channel.
PThreadLocalStorage< Status > m_status[NumErrorGroups+1]
Definition: channel.h:749
Errors
Normalised error codes.
Definition: channel.h:227
atomic< P_INT_PTR > os_handle
The operating system file handle return by standard open() function.
Definition: channel.h:735
virtual bool CloseBaseWriteChannel()
Close the base channel of channel indirection using PIndirectChannel.
High level protocol failure.
Definition: channel.h:241
int m_errorNumber
OS error returned after operation completed.
Definition: channel.h:516
void SetReadTimeout(const PTimeInterval &time)
Set the timeout for read operations.
~PChannel()
Close down the channel.
Error during Read() operation.
Definition: channel.h:252
Definition: channel.h:592
PBoolean SetErrorValues(Errors errorCode, int osError, ErrorGroup group=LastGeneralError)
Set error values to those specified.
virtual PString GetName() const
Get the platform and I/O channel type name of the channel.
Definition: channel.h:779
void SetWriteTimeout(const PTimeInterval &time)
Set the timeout for write operations to complete.
PINDEX m_length
Maximum number of bytes to read into the buffer.
Definition: channel.h:512
PINDEX m_lastCount
Last read/write count.
Definition: channel.h:739
bool Initialise(PChannel *channel, CompletionFunction onComplete)
#define free(p)
Override of system call for memory check system.
Definition: object.h:1870
PChannel * m_channel
Definition: channel.h:519
virtual bool FlowControl(const void *flowData)
Flow Control information Pass data to the channel for flowControl determination.
Abstract class defining I/O channel semantics.
Definition: channel.h:103
fd_set * set
Definition: channel.h:812
Parameters for asynchronous I/O operation.
Definition: channel.h:496
PBoolean SendCommandString(const PString &command)
Send a command meta-string.
Errors GetErrorCode(ErrorGroup group=NumErrorGroups) const
Get normalised error code.
bool PBoolean
Definition: object.h:174
virtual pos_type seekpos(pos_type, ios_base::openmode=ios_base::in|ios_base::out)
int ReadCharWithTimeout(PTimeInterval &timeout)
Read a character with specified timeout.
intptr_t P_INT_PTR
Definition: object.h:2646
Definition: channel.h:785
Operations buffer was too small for data.
Definition: channel.h:239
The character string class.
Definition: pstring.h:108
virtual bool ReadAsync(AsyncContext &context)
Begin an asynchronous read from channel.
virtual int_type underflow()
virtual int_type overflow(int_type=EOF)
virtual PINDEX GetLastReadCount() const
Get the number of bytes read by the last Read() call.
PChannelStreamBuffer & operator=(const PChannelStreamBuffer &sbuf)
ErrorGroup
Error groups.
Definition: channel.h:251
Operation fail due to channel not being open yet.
Definition: channel.h:236
virtual PBoolean Read(void *, PINDEX)
Low level read from the channel.
Miscellaneous error.
Definition: channel.h:240
Operation fail due to insufficient memory.
Definition: channel.h:235
virtual PINDEX SetLastReadCount(PINDEX count)
P_fd_set & operator+=(intptr_t fd)
virtual PBoolean Write(const void *buf, PINDEX len, const void *)
Low level write to the channel with marker.
Definition: channel.h:439
virtual void OnWriteComplete(AsyncContext &context)
User callback function for when a WriteAsync() call has completed or timed out.
AsyncNotifier m_notifier
Notification function for when asynchronous operation complete.
Definition: channel.h:513
Error during Write() operation.
Definition: channel.h:253
virtual P_INT_PTR GetHandle() const
Get the integer operating system handle for the channel.
virtual PBoolean IsOpen() const
Determine if the channel is currently open.
int m_lastErrorNumber
The operating system error number (eg as returned by errno).
Definition: channel.h:741
Open fail due to device already open for exclusive use.
Definition: channel.h:233
PTimeInterval GetReadTimeout() const
Get the timeout for read operations.
Operation was interrupted.
Definition: channel.h:238
P_fd_set & operator=(intptr_t fd)
virtual PString GetErrorText(ErrorGroup group=NumErrorGroups) const
Get error message description.
Cannot use channel at this time.
Definition: channel.h:242
virtual int ReadChar()
Read a single character from the channel.
virtual bool CloseBaseReadChannel()
Close the base channel of channel indirection using PIndirectChannel.
P_ALIGN_FIELD(CompletionFunction, m_onComplete, 16)
virtual PChannel * GetBaseReadChannel() const
Get the base channel of channel indirection using PIndirectChannel.
void(PChannel::* CompletionFunction)(AsyncContext &)
Definition: channel.h:520
#define PNEW_AND_DELETE_FUNCTIONS(align)
Definition: object.h:1908
PBoolean SetBufferSize(PINDEX newSize)
Set the iostream buffer size for reads and writes.
virtual bool SetLocalEcho(bool localEcho)
Set local echo mode.
void OnIOComplete(PINDEX length, int errorNumber)
~P_fd_set()
Definition: channel.h:790
int GetErrorNumber(ErrorGroup group=NumErrorGroups) const
Get OS errro code.
PBoolean IsPresent(intptr_t fd) const
AsyncContext(void *buf=NULL, PINDEX len=0, const AsyncNotifier ¬ifier=AsyncNotifier())
void * m_buffer
Pointer to a block of memory to receive the read bytes.
Definition: channel.h:511
A channel that does nothing.
Definition: channel.h:773
Write fail due to disk full.
Definition: channel.h:231
virtual pos_type seekoff(std::streamoff, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out)
virtual PBoolean ConvertOSError(P_INT_PTR libcReturnValue, ErrorGroup group=LastGeneralError)
Convert an operating system error into platform independent error.
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
PChannelStreamBuffer(PChannel *chan)
PBoolean WriteChar(int c)
Write a single character to the channel.