larten
Junior Member level 3
- Joined
- Aug 6, 2012
- Messages
- 25
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,437
Hi,
I wrote some code for send and receive data using UDP but there is a strange problem. when I test send data or receive data separately it works but when I want to send the data that I receive send part won't work at all.
I hope you can help me with this.
Here is my code:
I wrote some code for send and receive data using UDP but there is a strange problem. when I test send data or receive data separately it works but when I want to send the data that I receive send part won't work at all.
I hope you can help me with this.
Here is my code:
Code:
switch (UDPState)
{
case UDP_OPEN_SOCKET:
// RemoteIP.v[0] = (192ul);
// RemoteIP.v[1] = (168ul);
// RemoteIP.v[2] = (1ul);
// RemoteIP.v[3] = (100ul);
MyUDPSocket = UDPOpenEx(0,UDP_OPEN_SERVER,UDP_LOCAL_PORT,UDP_REMOTE_PORT);
if (MyUDPSocket == INVALID_UDP_SOCKET)
break;
else
UDPState = UDP_SEND;
break;
case UDP_SEND:
if(!UDPIsPutReady(MyUDPSocket))
break;
UDPPutString((BYTE*)buffer);
UDPFlush();
UDPState = UDP_LISTEN;
break;
case UDP_LISTEN:
if(!UDPIsGetReady(MyUDPSocket))
break;
for(i = 0; i < 20; i++)
buffer[i] = 0;
Result = UDPGetArray((BYTE*)buffer,19);
UDPDiscard();
if(Result != 0)
{
putsUART((unsigned int*)"UDP LISTEN = ");
putsUART((unsigned int*)buffer);
UDPState = UDP_SEND;
}
break;
case UDP_CLOSE_SOCKET:
break;
default:
;
}