hi folks,
presently i written a sample source code for sending data through udp socket but i am getting abort exeception error while sending the data .pls provide valuable sugestion for to resolve my probem…
The sample udp send source code and exection output shown below ,
struct sockaddr_in si_me, si_other,si_other2;
struct sockaddr_in si_send;
int rlen = sizeof(si_other),slen = sizeof(si_other2),recv_len;
char buf[BUFLEN];
int send_rcv=0;
#define MSG_7 7
#define THREAD_STACK_SIZE 16384
void udp_app_send(unsigned long unused)
{
(void)unused;
SOCKET sock;
//create a UDP socket
struct sockaddr_in addr = {0};
if ((sock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
{
die(“socket2”);
}
// zero out the structure
memset((char *) &si_send, 0, sizeof(si_send));
si_send.sin_family = AF_INET;
si_send.sin_port = htons(NA_UDP_PORT_SND);
si_send.sin_addr.s_addr = htonl(INADDR_ANY);
//bind socket to port
if( bind(sock , (struct sockaddr*)&si_send, sizeof(si_send) ) == -1)
{
die(“bind2”);
}
printf("Waiting for send data…
");
//keep listening for data
while(1)
{
if(send_rcv==1)
{
strcat (buf,“_Append”);
if (sendto(sock,buf,recv_len+MSG_7, 0, (struct sockaddr *)&addr,sizeof(addr)) == -1)
{
die("sendto()");
}
else
{
send_rcv=0;
memset((char *) &buf, 0, sizeof(buf));
printf("Message_Sent :%s
" , buf);
printf("Transmitted packet from %s Port No:%d
“, inet_ntoa(si_other.sin_addr), ntohs(si_other.sin_port)); //print details of the client/peer and the data transmitted
printf(”-----------------------------------------------------------------------------
");
}
printf("after send_rcv : %d",send_rcv);
}
}
close(sock);
}
hyperterminal output:
NET+OS Version 7.5.2.2
Copyright (c) 1997-2011, 2013 Digi International, Inc.
PLATFORM: connectwiem9210 4M/8M [Jul 08 2014 14:37:30]
APPLICATION: FTP SERVER [Jul 16 2014 17:45:40]
NETWORK INTERFACE PARAMETERS:
Wireless IP address is 192.168.1.16
Wireless subnet mask is 255.255.255.0
Wireless IP address of default gateway to other networks is 192.168.1.1
Wireless Network type: Access Point/Infrastructure
Wireless SSID is Phoenix1
Wireless Protocol: 802.11b
Wireless powersave disabled
Wireless Security: Open
HARDWARE PARAMETERS:
Serial channels will use a baud rate of 9600
This board’s serial number is N99999999
This board’s Wireless MAC Address is 00:40:9D:4A:75:1C
After board is reset, start-up code will wait 16 seconds
Press any key in 16 seconds to change these settings.
Serial CLI Started
IAM:AUTO-CONFIGURED IPv6 FE80::240:9DFF:FE4A:751C on wln0:3
IAM:STATIC IPv4 192.168.1.16 on wln0
Network IP configured.
UDP Bridge started
Waiting for data…
FTP Bridge started
Waiting for send data…
FTP SERVER Ready.
IAM:AUTOIP IPv4 169.254.202.81 on wln0:0
MeWaiting for data…
sendto()
Abort Exception
CONTEXT: THREAD
Thread Name: Root Thread
Thread ID:54485244
Thread Stack Start Address:0078AB48
Thread Stack End Address:00790B47
Program Counter :0017C44C
Stack Pointer :00785B40
Current program status Register :20000097
R00:00000001 R01:00000004
R02:00000804 R03:0026F7FC
R04:00000000 R05:0026FAEC
R06:0078250C R07:0026FAE0
R08:00178CEC R09:00000000
R10:00000000 R11:00790964
R12:00000000