Slide 54
Slide 54 text
mrbc_value TCPClient_send(const char *host, int port, mrbc_vm *vm, mrbc_value *send_data, bool is_tls)
{
ip_addr_t ip;
mrbc_value ret;
get_ip(host, &ip);
if(!ip4_addr_isloopback(&ip)) {
char ip_str[16];
ipaddr_ntoa_r(&ip, ip_str, 16);
mrbc_value recv_data = mrbc_string_new(vm, NULL, 0);
tcp_connection_state *cs = TCPClient_connect_impl(&ip, host, port, send_data, &recv_data, vm, is_tls);
while(TCPClient_poll_impl(&cs))
{
sleep_ms(200);
}
// recv_data is ready after connection is complete
ret = recv_data;
} else {
ret = mrbc_nil_value();
}
return ret;
}
picoruby/mrbgems/picoruby-net/ports/rp2040/net.c 54