Exemplo n.º 1
0
/* Send TCP transport data packet */
void
tcp_send(STREAM s)
{
    int length = s->end - s->data;
    int sent, total = 0;

#ifdef WITH_SCARD
    scard_lock(SCARD_LOCK_TCP);
#endif
    while (total < length)
    {
        sent = send(g_sock, s->data + total, length - total, 0);
        if (sent <= 0)
        {
            if (sent == -1 && TCP_BLOCKS)
            {
                tcp_can_send(g_sock, 100);
                sent = 0;
            }
            else
            {
                error("send: %s\n", TCP_STRERROR);
                return;
            }
        }
        total += sent;
    }
#ifdef WITH_SCARD
    scard_unlock(SCARD_LOCK_TCP);
#endif
}
Exemplo n.º 2
0
/* Send data from stream to tcp socket.
 * Will block until all data has been sent. */
void
tcp_send(rdpTcp * tcp, STREAM s)
{
	int sent = 0;
	int total = 0;
	int length = s->end - s->data;

#ifndef DISABLE_TLS
	if (tcp->iso->mcs->sec->tls_connected)
	{
		tls_write(tcp->iso->mcs->sec->ssl, (char*) s->data, length);
	}
	else
#endif
	{
		while (total < length)
		{
			while (total < length)
			{
				sent = send(tcp->sock, s->data + total, length - total, MSG_NOSIGNAL);
				if (sent <= 0)
				{
					if (sent == -1 && TCP_BLOCKS)
					{
						tcp_can_send(tcp->sock, 100);
						sent = 0;
					}
					else
					{
						ui_error(tcp->iso->mcs->sec->rdp->inst, "send: %s\n", TCP_STRERROR);
						return;
					}
				}
				total += sent;
			}
		}
	}
}
Exemplo n.º 3
0
Arquivo: tcp.c Projeto: jeppeter/vbox
/* Send TCP transport data packet */
void
tcp_send(STREAM s)
{
	int ssl_err;
	int length = s->end - s->data;
	int sent, total = 0;

	if (g_network_error == True)
		return;

#ifdef WITH_SCARD
	scard_lock(SCARD_LOCK_TCP);
#endif
	while (total < length)
	{
		if (g_ssl)
		{
			sent = SSL_write(g_ssl, s->data + total, length - total);
			if (sent <= 0)
			{
				ssl_err = SSL_get_error(g_ssl, sent);
				if (sent < 0 && (ssl_err == SSL_ERROR_WANT_READ ||
						 ssl_err == SSL_ERROR_WANT_WRITE))
				{
					tcp_can_send(g_sock, 100);
					sent = 0;
				}
				else
				{
#ifdef WITH_SCARD
					scard_unlock(SCARD_LOCK_TCP);
#endif

					error("SSL_write: %d (%s)\n", ssl_err, TCP_STRERROR);
					g_network_error = True;
					return;
				}
			}
		}
		else
		{
			sent = send(g_sock, s->data + total, length - total, 0);
			if (sent <= 0)
			{
				if (sent == -1 && TCP_BLOCKS)
				{
					tcp_can_send(g_sock, 100);
					sent = 0;
				}
				else
				{
#ifdef WITH_SCARD
					scard_unlock(SCARD_LOCK_TCP);
#endif

					error("send: %s\n", TCP_STRERROR);
					g_network_error = True;
					return;
				}
			}
		}
		total += sent;
	}
#ifdef WITH_SCARD
	scard_unlock(SCARD_LOCK_TCP);
#endif
}