Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

udp receive problem under nios

7 views
Skip to first unread message

bjzh...@gmail.com

unread,
May 10, 2008, 12:40:12 AM5/10/08
to
Hi ,everyone,now I use the NicheStack tcp/ip stack for sending and
receiving the udp packets, the hardware platform is as follows,cyc-II
70 ,nios-ii,lan91c111 and so on.the receive code is as follows.
void RecvData(int socket)
{
INT8U rx_buf[1024];
INT8U *rx_buf_pos;
int recv_len;
struct sockaddr_in from_addr;
int fromLen = 100;

rx_buf_pos = rx_buf;

recv_len = recvfrom(socket,rx_buf,100,0,(struct
sockaddr*)&from_addr,&fromLen);
//recv_len = recv(recv_socket,rx_buf,sizeof(rx_buf),0);
if(recv_len == SOCKET_ERROR)
{
printf("Socket error!!\n");
}
else
{
printf("receive %d bytes from 192.168.1.2\n",recv_len);
}
}
the send packet is normal but the receive code seem to be something
wrong,It doesn't work,if the packet is short the funciton doesn't have
any return,if the packet upto 1024 bytes,the console continuous print
"Your Ethernet MAC address is 00:50:04:ee:0a:0d
Static IP Address is 192.168.1.3"
Another strage phenomenon is that the tcp/ip stack will be failed to
initialize if I remove the second line in the follow task
void SSSSimpleSocketServerTask()
{
int send_socket;
static SSSConn conn;
struct sockaddr_in far_addr;
struct sockaddr_in local_addr;
int recv_socket;
............................
}
And the conn is not used in this task,I don't know why,all the data
code is changed based the simple socket server demo code.
Can anyone give any advice,Thanks!

0 new messages