/****************************************************************************** * NETCON_send * Basically calls 'send()' unless we should use SSL * number of chars send is put in *sent */ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, int *sent /* out */) { /* send is always blocking. */ set_socket_blocking(connection, TRUE); if(!connection->secure) { *sent = sock_send(connection->socket, msg, len, flags); return *sent == -1 ? WSAGetLastError() : ERROR_SUCCESS; } else { const BYTE *ptr = msg; size_t chunk_size; *sent = 0; while(len) { chunk_size = min(len, connection->ssl_sizes.cbMaximumMessage); if(!send_ssl_chunk(connection, ptr, chunk_size)) return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; *sent += chunk_size; ptr += chunk_size; len -= chunk_size; } return ERROR_SUCCESS; } }
/****************************************************************************** * NETCON_send * Basically calls 'send()' unless we should use SSL * number of chars send is put in *sent */ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, int *sent /* out */) { if(!connection->secure) { *sent = sock_send(connection->socket, msg, len, flags); if (*sent == -1) return sock_get_error(errno); return ERROR_SUCCESS; } else { const BYTE *ptr = msg; size_t chunk_size; *sent = 0; while(len) { chunk_size = min(len, connection->ssl_sizes.cbMaximumMessage); if(!send_ssl_chunk(connection, ptr, chunk_size)) return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; *sent += chunk_size; ptr += chunk_size; len -= chunk_size; } return ERROR_SUCCESS; } }
BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int *sent ) { if (!netconn_connected( conn )) return FALSE; if (conn->secure) { const BYTE *ptr = msg; size_t chunk_size; *sent = 0; while(len) { chunk_size = min(len, conn->ssl_sizes.cbMaximumMessage); if(!send_ssl_chunk(conn, ptr, chunk_size)) return FALSE; *sent += chunk_size; ptr += chunk_size; len -= chunk_size; } return TRUE; } if ((*sent = sock_send( conn->socket, msg, len, 0 )) == -1) { set_last_error( sock_get_error( errno ) ); return FALSE; } return TRUE; }