Hello,
is there any example for this use case:
Mask: 255.255.255.0
My device IP: 192.168.0.1
I need UDP communication working as client to server. My device would be server.
I am receiving packets from port 5000 and any IP within same network as my device. This packet arrives with source port (always same) 5001.
After I process incoming message, I have to send response to IP address from which I have got received request with source port set to 5000 (my receive port) and 5001 as destination port (port that I have get from request).
Is there any example for this? Do I need 2 sockets for this or one is enough? I have found example AN4644CW and there are two sockets for something familiar to my problem but when I have tried to change it for my needs, communication always got stuck. Currently I am using 2 sockets as it in example and closing and reopening them but it does not working.
Solved! Go to Solution.
I attached demo.c and config.h already, if you can't download it or you can't see them, you can submit a request
How to submit a new question for NXP Support
My test result is as following.
Regardd
Daniel
Hi Jaroslave:
I think you only need one socket to communicate.
I made a simple udp server demo , I modified this demo based on Freescale_MQX_4_2\rtcs\examples\eth_to_serial, you can replace with the attached files.
The udp server source port is 5000, it can receive all packets.
If you need to receive packets only with port 5001, you can change this line in demo.c
server_socket_addr.sin_addr.s_addr = INADDR_ANY; -> server_socket_addr.sin_addr.s_addr = 5001;
Regards
Daniel
Hi Daniel,
I think you forgot to attach files with your example. Could you please attach them?
I attached demo.c and config.h already, if you can't download it or you can't see them, you can submit a request
How to submit a new question for NXP Support
My test result is as following.
Regardd
Daniel
Thank you very much. It is working now. :smileyhappy: