Hi,
i am using KDS3.0 and KSDK1.3.0 example. i am using FRDMk64 board and ethernet_to_serial example.in my application code my device act as Client so i will connect to server. its working fine. but every disconnect and connect my source port should change for that what i want to do..? where i can see source port assignment ..? actually i want to increase the source port number for every connection.how to do that..?
NOTE: i want to change device PORT number not server PORT number.
regards,
sudhakar p
Hi
if you are using TCP sockets you must have a structure of type sockaddr_in. In field sin_port you may indicate the destination port. Refer to the snippet below.
#define DESTPORT 1030
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = 0;
addr.sin_addr.s_addr = INADDR_ANY;
error = bind(sock, &addr, sizeof(addr));
addr.sin_port = DESTPORT;
addr.sin_addr.s_addr = IPADDR(192,168,1,132); //Server address
error = connect(sock, &addr, sizeof(addr));
Regards,
Carlos