TCP connection

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP connection

Jump to solution
223 Views
CamiloA_
Contributor III

Hi guys, how are you? I`m having a problem regarding my TCP connection. If my device is connected to an IP of my LAN it works perfectly but when I want to go out to the cloud through my default gateway it connects randomly, almost never, but sometimes it fulfills the connection. I don´t know what`s happening because it seems to be fine and it connects sometimes. It`s not a cable or physical connection problem I thoroughly oversaw it, and like i saud it works fine in a LAN. I`m setting my connection like this:

typedef struct sockaddr_in {

   uint_16  sin_family;

   uint_16  sin_port;

   in_addr  sin_addr;

} sockaddr_in;

       sockaddr_in addr;

       addr.sin_family = AF_INET;

       addr.sin_port = puerto; // Destination port where the server is listening

       addr.sin_addr.s_addr = IPADDR(d_ip0,d_ip1,d_ip2,d_ip3); // Server IP address where the clients connects

       ip_data.gateway = IPADDR(g_puerta0,g_puerta1,g_puerta2,g_puerta3);

       ip_data.mask = IPADDR(g_mascara0,g_mascara1,g_mascara2,g_mascara3);

       sock = socket(AF_INET, SOCK_STREAM, 0);

       //error = bind(sock, &addr, sizeof(addr)); // I`ve tried with or without this line but it doesn´t change at all.

Thank you very much and have a nice week.

1 Solution
106 Views
DavidS
NXP Employee
NXP Employee

Hi Camilo,

I'm not super knowledgable on Ethernet but am giving my gut feedback.

Have you looked at the MQX/docs/RTCS/RTCSUG.pdf ?

It shows how to configure the RTCS as well as add gateways in chapter 2.

Chapter 3 goes into detail about using sockets.

So I'm guessing the order might be important.

Hopefully this helps.

Regards,

David

View solution in original post

1 Reply
107 Views
DavidS
NXP Employee
NXP Employee

Hi Camilo,

I'm not super knowledgable on Ethernet but am giving my gut feedback.

Have you looked at the MQX/docs/RTCS/RTCSUG.pdf ?

It shows how to configure the RTCS as well as add gateways in chapter 2.

Chapter 3 goes into detail about using sockets.

So I'm guessing the order might be important.

Hopefully this helps.

Regards,

David

View solution in original post