Skip to content

Commit

Permalink
Prototype of SecureTransport for SSL. Note this is not safe to use as…
Browse files Browse the repository at this point in the history
… proper certificate validation is still being worked on.

git-svn-id: http://svn.mulberrymail.com/mulberry/Mulberry/branches/v4.1d1@491 a91246af-f21b-0410-bd1c-c3c7fc455132
  • Loading branch information
cyrusdaboo authored and mbert committed Apr 17, 2015
1 parent 4b9cdd0 commit b6b7ada
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 27 deletions.
44 changes: 33 additions & 11 deletions Sources_Common/Mail/Network/CTCPSocket.cp
Expand Up @@ -1772,7 +1772,19 @@ void CTCPSocket::TCPReceiveData(char* buf, long* len)

// Yield before to get any user abort
TCPYield();

while (!_ReceiveData(buf, len)) {
// Select yield while waiting to unblock
TCPSelectYield(true);
}

// Reset tickle timer
TimerReset();
}

// Receive data
bool CTCPSocket::_ReceiveData(char* buf, long* len)
{
// Get any data present at the moment
int result;
while((result = ::recv(mSocket, buf, *len, 0)) == SOCKET_ERROR)
Expand All @@ -1781,10 +1793,7 @@ void CTCPSocket::TCPReceiveData(char* buf, long* len)

// Check for failure
if (err == EWOULDBLOCK)

// Select yield while waiting to unblock
TCPSelectYield(true);

return false;
else
{
TCPAbort(true);
Expand All @@ -1810,9 +1819,7 @@ void CTCPSocket::TCPReceiveData(char* buf, long* len)
}

*len = result;

// Reset tickle timer
TimerReset();
return true;
}

// S E N D I N G D A T A _____________________________________________________________________________________
Expand All @@ -1827,7 +1834,23 @@ void CTCPSocket::TCPSendData(char* buf, long len)

// Yield before to get any user abort
TCPYield();

long result = 0;
while ((result = _SendData(buf, len)) != 0) {
// Select yield while waiting to unblock
TCPSelectYield(false);

buf += result;
len += result;
}

// Reset tickle timer
TimerReset();
}

// Send data
long CTCPSocket::_SendData(char* buf, long len)
{
// Send data in blocks of buffer size
char* p = buf;
while(len)
Expand All @@ -1843,7 +1866,7 @@ void CTCPSocket::TCPSendData(char* buf, long len)
if (err == EWOULDBLOCK)

// Select yield while waiting to unblock
TCPSelectYield(false);
return len;

else
{
Expand All @@ -1863,7 +1886,6 @@ void CTCPSocket::TCPSendData(char* buf, long len)
p += result;
}
}

// Reset tickle timer
TimerReset();

return 0;
}
3 changes: 3 additions & 0 deletions Sources_Common/Mail/Network/CTCPSocket.h
Expand Up @@ -218,6 +218,9 @@ class CTCPSocket

void TCPCreateSocket();

virtual bool _ReceiveData(char* buf, long* len); // Receive some data directly
virtual long _SendData(char* buf, long len); // Send data

// Yielding
void TCPYield();
void TCPSelectYield(bool read, unsigned long secs = -1);
Expand Down

0 comments on commit b6b7ada

Please sign in to comment.