Exemplo n.º 1
0
void client(struct network_address* addr, int command, const char* arg)
{
	char buffer[1024] = {0};
	size_t data_len = 0;
	struct network_socket* sock = network_tcp_create(addr);
	enum network_result res;
	network_tcp_connect(sock, addr);

	switch(command)
	{
		case 'q':
			strncpy(buffer, "QUIT\n\n", sizeof(buffer));
			break;
		case 'd':
			snprintf(buffer, sizeof(buffer), "DIR %s\n\n", arg);
			break;
		case 'f':
			snprintf(buffer, sizeof(buffer), "FIND %s\n\n", arg);
			break;
	}

	data_len = strlen(buffer);
	if(data_len)
	{
		network_tcp_send_all(sock, buffer, data_len);
		do
		{
			uint num_recv = 0;
			res = network_tcp_receive(sock, buffer, sizeof(buffer)-1, &num_recv);
			buffer[num_recv]= '\0';
			puts(buffer);
		} while(res == NETWORK_RESULT_OK);
	}
	network_tcp_destroy(sock);
}
Exemplo n.º 2
0
wiced_result_t wiced_tcp_receive( wiced_tcp_socket_t* socket, wiced_packet_t** packet, uint32_t timeout )
{
    wiced_assert("Bad args", (socket != NULL) && (packet != NULL) );

    WICED_LINK_CHECK_TCP_SOCKET( socket );

#ifndef WICED_DISABLE_TLS
    if ( socket->tls_context != NULL )
    {
        return wiced_tls_receive_packet( socket, packet, timeout );
    }
    else
#endif /* ifndef WICED_DISABLE_TLS */
    {
        return network_tcp_receive( socket, packet, timeout );
    }
}
Exemplo n.º 3
0
tls_result_t tls_host_receive_packet(ssl_context* ssl, tls_packet_t** packet, uint32_t timeout)
{
    tls_result_t              result = TLS_RECEIVE_FAILED;
    switch(ssl->transport_protocol)
    {
        case TLS_TCP_TRANSPORT:
            result = (tls_result_t) network_tcp_receive( (wiced_tcp_socket_t*) ssl->receive_context, (wiced_packet_t**) packet, timeout );
            break;

        case TLS_EAP_TRANSPORT:
#ifndef DISABLE_EAP_TLS
            result = (tls_result_t) supplicant_receive_eap_tls_packet( ssl->receive_context, packet, timeout );
            break;
#endif /* DISABLE_EAP_TLS */

        case TLS_UDP_TRANSPORT:
        default:
            wiced_assert( "unknown transport", 1 == 0 );
            break;
    }

    return result;
}
Exemplo n.º 4
0
tls_result_t tls_host_receive_packet(void* context, tls_packet_t** packet, uint32_t timeout)
{
    return network_tcp_receive( (wiced_tcp_socket_t*) context, (wiced_packet_t**) packet, timeout );
}