Quantcast
Channel: Wireless Connectivity
Viewing all articles
Browse latest Browse all 116964

Forum Post: RE: Non Blocking UDP receive

$
0
0

Hi,

I have a problem with recvfrom function. I can't recive any data from my desktop computer. this is code: 

void reciveUDP (void)
{
fd_set readSet,writeSet,exceptSet;
volatile long bytesSent = 0;
timeval timeout;

timeout.tv_sec = 5;
timeout.tv_usec = 0;//50*100;

memset(&timeout, 0, sizeof(timeval));


char ip[4];
char port1[12];
volatile long send;

//configure header of communication
serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

//open port

adresa.sa_family = AF_INET;

//set port

port=3000;
adresa.sa_data[0] = (port & 0xff00)>>8;
adresa.sa_data[1] = (port & 0x00ff);


//set IP address

ip[3]= adresa.sa_data[2] = 0xc0; //adress of my router
ip[2]= adresa.sa_data[3] = 0xa8;
ip[1]= adresa.sa_data[4] = 0x01;
ip[0]= adresa.sa_data[5] = 0x64;

sendString("IP");
printIpAddr(ip);

duzinaadrese = sizeof(sockaddr);
bind(serverSocket,&adresa, duzinaadrese);


FD_ZERO( &readSet );
FD_ZERO( &writeSet );
FD_ZERO( &exceptSet );

FD_SET( serverSocket, &readSet);
// FD_SET( serverSocket, &writeSet);

int rc = select(serverSocket+1, &readSet,NULL, NULL, &timeout );

// perform send on the write socket if it is ready to receive next chunk of data
if (FD_ISSET(serverSocket, &writeSet) )
{
}

// perform read on read socket if data available
if (FD_ISSET(serverSocket, &readSet))
{

bytesSent=recvfrom(serverSocket, pucCC3000_Rx_Buffer ,sizeof(pucCC3000_Rx_Buffer), 0, &adresa, &duzinaadrese );

if(bytesSent<=0)
{
// No data received by device
DispatcherUartSendPacket((unsigned char*)pucUARTNoDataString, sizeof(pucUARTNoDataString));
}
else
{
// Send data to UART...
DispatcherUartSendPacket(pucCC3000_Rx_Buffer, CC3000_APP_BUFFER_SIZE);
}
}

Can someone tell me, what i do wron when i can't recive any data. 

I useing MSP430FR5739 with cc3000  and patch V1.11


Viewing all articles
Browse latest Browse all 116964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>