[ SimpleEmailClient | Source | Keywords | Summary | Ancestors | All Members | Descendants ]
Back to the top of CSimpleSocket
This class provides an API for accessing Windows Socket similar to the MFC CSocket class, but with additional features:
CAUTION: do not share instances of this class between threads. This class is derived from CSocket is suffers the same limitations as its base class (as described in MSDN articles Q175668 and Q140527).
Back to the top of CSimpleSocket
To use this class:
Back to the top of CSimpleSocket
// Create an instance CSimpleSocket oSocket;// Create the socket if (oSocket.Create()) { // Connect to the server if (oSocket.Connect(m_szServerName, m_uPortNumber)!=0) { // Set timeout value to 30 seconds oSocket.SetTimeOut(30000);
CString strResponse; // Read response from the server if (oSocket.ReceiveLine(strResponse) != SOCKET_ERROR) {
// Send data to server oSocket.Send("QUIT\r\n");
} } }
// socket is closed automatically when the object oSocket is deleted.
Back to the top of CSimpleSocket
Author Emmanuel KARTMANN
Date Tuesday 11/17/98
Back to the top of CSimpleSocket
CSocket CAsyncSocket
MSDN articles Q175668 and Q140527
Back to the top of CSimpleSocket
BOOL Connect( LPCTSTR lpszHostAddress, UINT nHostPort, UINT uTimeOut );
Purpose: establish a connection to an unconnected stream or datagram socket.
Parameters:
Description : overrides CAsyncSocket::Connect (implements timer with multithreading)
BOOL Connect( LPCTSTR lpszHostAddress, UINT nHostPort, UINT uTimeOut = INFINITE);
Back to the top of CSimpleSocket
CSimpleSocket(UINT uTimeOut );
Purpose: create an instance of the class
Parameters:
Description :
CSimpleSocket(UINT uTimeOut = 0);
Back to the top of CSimpleSocket
Purpose: delete an instance of the class
Parameters: none (C++ destructor)
Return value : none (C++ destructor)
Description :
~CSimpleSocket();
Back to the top of CSimpleSocket
int ReceiveString(CString& str, int nFlags );
Purpose: receives data (string only) from the socket.
Parameters:
Description : This function times out after (m_uTimeOut) milliseconds
int ReceiveString(CString& str, int nFlags = 0);
Back to the top of CSimpleSocket
int ReceiveLine(CString& szLine, int nFlags );
Purpose: receives next line (string data only) from the socket.
Parameters:
Description : Reads data up to the next CRLF character. This function times out after (m_uTimeOut) milliseconds
int ReceiveLine(CString& szLine, int nFlags = 0);
Back to the top of CSimpleSocket
int Receive(void* lpBuf, int nBufLen, int nFlags );
Purpose: receive data from a socket (with timeout)
Parameters:
Description : overrides method CAsyncSocket::Receive()
virtual int Receive(void* lpBuf, int nBufLen, int nFlags = 0);
Back to the top of CSimpleSocket
int Send(const void* lpBuf, int nBufLen, int nFlags );
Purpose: send data to the socket (with timeout)
Parameters:
Description : overrides method CAsyncSocket::Send()
virtual int Send(const void* lpBuf, int nBufLen, int nFlags = 0);
Back to the top of CSimpleSocket
int Send(CString &szString, int nFlags );
Purpose: send string to the socket (with timeout)
Parameters:
Description : overrides method CAsyncSocket::Send()
virtual int Send(CString &szString, int nFlags = 0);
Back to the top of CSimpleSocket
int Send(LPCTSTR lpszString, int nFlags );
Purpose: send string to the socket (with timeout)
Parameters:
Description : overrides method CAsyncSocket::Send()
virtual int Send(LPCTSTR lpszString, int nFlags = 0);
Back to the top of CSimpleSocket
void SetTimeOut(UINT uTimeOut );
Purpose: set the timeout value for all socket operations
Parameters:
Description : Send/Receive methods use the timeout value in their implementation.
void SetTimeOut(UINT uTimeOut = 0);
Back to the top of CSimpleSocket
Purpose: returns the timeout value for all socket operations
Parameters: none
Return value : UINT = timeout value, in milliseconds (0 for infinite wait)
Description :
UINT GetTimeOut() const;
Back to the top of CSimpleSocket
Back to the top of CSimpleSocket
Back to the top of CSimpleSocket
Back to the top of CSimpleSocket
Report problems to jkotula@stratasys.com