RTCS stream socket - Question about fixing the sorce port by using connect()/setsockopt()

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

RTCS stream socket - Question about fixing the sorce port by using connect()/setsockopt()

596 Views
CaesarI
Contributor III

Hi everybody,

normally when we use RTCS to open a TCP connection as a client, we use the RTCS API to do this. (and it works fine)

We set the communication port (80 - http) and the API act, as we expect...

Now I have to open one and better more TCP connections as well using the same source port (destination port is 80 - http - as well).

I did'nt found any socket option or other way to do this. Is'nt it possible?

How to fix the the sorce port by using connect()/setsockopt()?

best regards,

Caesar

PS: MQX 3.8, 4.0, 4.1

Labels (1)
0 Kudos
3 Replies

372 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Caesarl,

You can not open two sockets in the same port. If you already used port 80 then you need to use another port. You should be able to do the same as you did for the port 80. just change the port, try 81.


Regards,
Garabo

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

372 Views
CaesarI
Contributor III

Hi Garabo,

of course you can open some client connections simultaneously on one port number - listen ports (server) you can open one per port only, but that was not the question....

The question is: How to determine the source port number during open a client connection by using connect()?

best regards

0 Kudos

372 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Caesarl,

You right, as a client you can open as many connections as the server allows (i.e. Daemon servers).

For standard some ports are already assigned and that would be the only way to know a port number before opening a connection to a server (HTTP is the example). The RFC for HTTP says that all HTTP server should be mounted in the port 80.

Regards,
Garabo

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos