Jump to content

how to know which local port is used for a tcp connection


Recommended Posts

hello again,

i have an opened TCP connection with a remote server which can send me data randomly in the time (it is a chat server)

so i need to know which local port is used for the connection in order to use the TCP listen component and so for reading data sent by the server.

thank you for your help

(ps: i dont want to use static port to solution this problem, i prefer when labview to choose dynamicaly a unused port , and sorry for my poor english)

Link to comment
hello again,

i have an opened TCP connection with a remote server which can send me data randomly in the time (it is a chat server)

so i need to know which local port is used for the connection in order to use the TCP listen component and so for reading data sent by the server.

thank you for your help

(ps: i dont want to use static port to solution this problem, i prefer when labview to choose dynamicaly a unused port , and sorry for my poor english)

Once the tcp connexion is opened, the proper function to use is TCP Read. TCP Listen is used to wait incoming connexions from clients.

Link to comment
thanks you for your help.

the problem with the TCP read component is that i am obligated to do a while loop to listen if something is coming.

isn't it more convenience to wait until something is coming??

thanks again

You have to use a loop anyway to gather the next piece of data so what is the problem? Set a large timeout on the Read function so it won't loop wildly. To abort the waiting Read function close the TCP connection and it will stop immediatly with an error.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.