Hi, i have created my own function for sending some buffer data over udp ipv4 by striping down loopback code. If i send data to lets say 192.168.137.1 and dont configure ethernet port on laptop to have that static ip whole EVB board is blocked when it enters in that send function. How can i avoid that blocking, so that it sends data to that IP no matter is that ip existing or not in network?
Code for that function:
void Client ( uint8_t ip[4], uint16_t port, char *buffer, int lenght_send){
uint8_t status;
datasize_t received_size;
datasize_t ret;
uint16_t sentsize;
uint8_t* mode_msg;
uint8_t sn = 1;
uint8_t loopback_mode = AS_IPV4;
if(loopback_mode == AS_IPV4)
{
mode_msg = msg_v4;
}else if(loopback_mode == AS_IPV6)
{
mode_msg = msg_v6;
}else
{
mode_msg = msg_dual;
}
getsockopt(sn, SO_STATUS,&status);
switch(status)
{
case SOCK_UDP:
received_size = (uint16_t) lenght_send;
sentsize = 0;
if(received_size>0)
{
while(sentsize != received_size){
ret = sendto(sn, (uint8_t*)buffer+sentsize, received_size-sentsize, ip, port, 4);
//if(ret < 0) return ret;
sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero.
}
}
break;
case SOCK_CLOSED:
switch(loopback_mode)
{
case AS_IPV4:
socket(sn,Sn_MR_UDP4, port, SOCK_IO_NONBLOCK);
break;
case AS_IPV6:
socket(sn,Sn_MR_UDP6, port, SOCK_IO_NONBLOCK);
break;
case AS_IPDUAL:
socket(sn,Sn_MR_UDPD, port, SOCK_IO_NONBLOCK);
break;
}
printf("%d:Opened, UDP loopback, port [%d] as %s\r\n", sn, port, mode_msg);
}
}