OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TSocketError Class Reference

TSocketError converts Windows Sockets errors to string messages. More...

#include <owl/wskerr.h>

Public Member Functions

 TSocketError (int error=0, unsigned sizeToAllocate=128)
 This function constructs the object with the error code and the size of the buffer to allocate.
 
virtual ~TSocketError ()
 This function destroys the allocated string.
 
 TSocketError (const TSocketError &src)
 Copies the error code and string.
 
TSocketErroroperator= (const TSocketError &src)
 This function copies the error code and string.
 
void Init (int error)
 This function initializes the error code.
 
int GetReasonValue () const
 This function returns the error code.
 
const tcharGetReasonString () const
 This function hands the pointer to the string to the caller.
 
tcharAppendError (const tchar *stringToAppendErrorTo, tchar *destination=0)
 This function appends the error string to whatever is in the string 'stringToAppendErrorTo' and put the result in 'destination'.
 
tcharAppendError (int stringResourceToAppendErrorTo, tchar *destination=0)
 This function is similar to AppendError(char*, char*), but the pre-string comes from a string resource and szStringToAppendErrorTo will be overwritten with what is in the string resource and appended to the Windows Sockets Error description.
 

Protected Member Functions

void GetErrorString ()
 Convert the error code to string.
 

Protected Attributes

int Error
 Error code.
 
size_t SizeToAllocate
 Size to allocate for String.
 
tcharString
 Error code converted to string.
 

Friends

bool operator== (const TSocketError &socketError1, const TSocketError &socketError2)
 This function tests for equality between two TSocketError objects.
 

Detailed Description

TSocketError converts Windows Sockets errors to string messages.

Definition at line 30 of file wskerr.h.

Constructor & Destructor Documentation

◆ TSocketError() [1/2]

owl::TSocketError::TSocketError ( int error = 0,
unsigned sizeToAllocate = 128 )

This function constructs the object with the error code and the size of the buffer to allocate.

Definition at line 24 of file wskerr.cpp.

References GetErrorString().

◆ ~TSocketError()

owl::TSocketError::~TSocketError ( )
virtual

This function destroys the allocated string.

Definition at line 36 of file wskerr.cpp.

References String.

◆ TSocketError() [2/2]

owl::TSocketError::TSocketError ( const TSocketError & src)

Copies the error code and string.

Definition at line 44 of file wskerr.cpp.

Member Function Documentation

◆ AppendError() [1/2]

tchar * owl::TSocketError::AppendError ( const tchar * stringToAppendErrorTo,
tchar * destination = 0 )

This function appends the error string to whatever is in the string 'stringToAppendErrorTo' and put the result in 'destination'.

You may want to put something specific about the error in the string and then use AppendError() to add the Winsock error code and description to it.

For example, you could say:

// MessageBox(TSocketError(WSAENOTCONN).AppendError("Unable to send your mail"),
// "Error", MB_OK);

And AppendError() will put "\n\nWinsock Error 10057: Socket is not presently connected" after the "Unable to send you mail" string. Quite convenient.

If destination is valid, destination provides the space for the result.

Note
It is assumed that desination has enough space. If destination is 0, our internal string buffer is used for the result.
Using the internal string changes the result of subsequent calls to GetReasonString. Use Init to reset the error string.

Definition at line 122 of file wskerr.cpp.

References _T, _tcscpy, GetReasonString(), SizeToAllocate, and String.

◆ AppendError() [2/2]

tchar * owl::TSocketError::AppendError ( int stringResourceToAppendErrorTo,
tchar * destination = 0 )

This function is similar to AppendError(char*, char*), but the pre-string comes from a string resource and szStringToAppendErrorTo will be overwritten with what is in the string resource and appended to the Windows Sockets Error description.

stringToAppendErrorTo must be able to hold at least 128 characters.

Definition at line 154 of file wskerr.cpp.

References AppendError().

◆ GetErrorString()

void owl::TSocketError::GetErrorString ( )
protected

Convert the error code to string.

This function gets a string, suitable for display, based on the nError value.

The previous string is deleted if necessary. Note that the string allocated must be at least 128 characters long. Even though the error strings you see don't have error numbers associated with them, the function prepends the error number to the szString before returning.

If you are writing string resources for the error strings, don't put error numbers in the string, because that will be done for you later.

Definition at line 170 of file wskerr.cpp.

References _T, COUNTOF, Error, SizeToAllocate, and String.

◆ GetReasonString()

const tchar * owl::TSocketError::GetReasonString ( ) const

This function hands the pointer to the string to the caller.

The caller shouldn't alter this string (because it doesn't belong to the caller).

Definition at line 96 of file wskerr.cpp.

References String.

◆ GetReasonValue()

int owl::TSocketError::GetReasonValue ( ) const

This function returns the error code.

Definition at line 87 of file wskerr.cpp.

References Error.

◆ Init()

void owl::TSocketError::Init ( int error)

This function initializes the error code.

Definition at line 78 of file wskerr.cpp.

References Error, and GetErrorString().

◆ operator=()

TSocketError & owl::TSocketError::operator= ( const TSocketError & src)

This function copies the error code and string.

Definition at line 55 of file wskerr.cpp.

References Error, SizeToAllocate, String, and strnewdup().

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const TSocketError & socketError1,
const TSocketError & socketError2 )
friend

This function tests for equality between two TSocketError objects.

The important criteria for determining equality is the error value. The string is unimportant.

Definition at line 69 of file wskerr.cpp.

Member Data Documentation

◆ Error

int owl::TSocketError::Error
protected

Error code.

Definition at line 50 of file wskerr.h.

◆ SizeToAllocate

size_t owl::TSocketError::SizeToAllocate
protected

Size to allocate for String.

Usually bigger than String so we can append to it.

Definition at line 51 of file wskerr.h.

◆ String

tchar* owl::TSocketError::String
protected

Error code converted to string.

Definition at line 53 of file wskerr.h.


The documentation for this class was generated from the following files: