send() to other socket

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

send() to other socket

677 Views
emanueletrapani
Contributor III

hi, i work on mqx 4.2, CW 10.6 and frdmk64f.

my application have, sometimes, a strange behaviour: while task 1 it does a trasparent between the uart and the socket X, another task, task 2, try to connect the socket Y to a remote server. A step of the connect process for socket Y is that my application, after the connect() function returns (it returns RTCS_OK also in the case that the remote server does not exist), it try to send a test packet to remote server so it can anderstand if the remote server exists or not( if the send() return a error). The strange thing is that, when the socket is created but not connected to the remote server (that not exists), the test packet is sent to the trasparent socket X, also if the send() return an error; and it cause to trasparent some problems. In other words, the send(socketY,...) send the packet to socketX.

this is not a problem of initialization variable; when i do the send()s the argument for socket definition is different between the trasparent send() and the send() of remote server connection. If the connection to the server has been established previously, all going well also in the case where the task test if the connection is still open sending another test_packet.

there is some behavior known of the send() function if the socket is created but not connect?

i hope i explaned well, sorry for my english.

thanks

Labels (1)
0 Kudos
Reply
3 Replies

430 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Emanuele,

My understanding is that you have next

- Taks1 -> Creates socketX -> Communicated UART to Ethernet through the socket

- Task2 -> Creates socketY -> Communicates with server

- socketY connect() returns RTCS_OK even if the server does not exist

- test packet that should be sent though socketY is sent through socketX

Questions:

- What is on the other side of socketX?

- What king of server is connecting socketY?

I think there is a parameter that is being overwritten in your application, this could explain that connect() is returning RTCS_OK because is indicating the connection with socketX and not socketY and therefore the test packet is sent through socketX. However I would need to see the code of you application to understand what could be wrong. You could isolate the tests by first checking only with socketX and then socketY, this would help to find where parameters are mixing.

Regards,

Carlos

0 Kudos
Reply

430 Views
emanueletrapani
Contributor III

ok, your understanding is correct.

- in the other side of socketX there are a pc application that receive the uart data through ethernet.

- my socketY is created and bind to a local_endpoint (the problem is the same if i leave the socketY in unbound state); then i try to connect it to a remote endpoint (IP and PORT of my remote server). in my test i use the tcp server of Hercules.

in my application i checked all the buffer and all the variables that i use. so i thought that the probem may not be at my application level. but on the other side i have some difficulties to replicate the problem in a very simple application like an example.

about connect() problem i opened a thread at https://community.freescale.com/thread/383555

and it return RTCS_OK also if my application is just one task with just one socket that try cyclically to connect to an inexistent server.

0 Kudos
Reply

430 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Emanuale,

you are right, I was able to reproduce this and it is not the expected behavior. I created a report and submitted to MQX development team. Report number is MQX-5682

meanwhile you can workaround this by activating a watchdog timer that expires before connect timeout. If the connect function is still trying to connect before a considerable time you may kill the task.

Best regards,

Carlos

0 Kudos
Reply