ganeshkumar1989 Posted December 23, 2011 Report Share Posted December 23, 2011 Hi, What is the best method to get the VI server port used by any Exe in execution, whose process name is known (How can the process name be mapped to the port number (VI server) used by that process)? We are currently using netstat to find the port number. The iphlpapi.dll system DLL methods also work by getting the entire list of Process ids and ports. But there might be a better method to achieve the same functionality (A method that directly maps the process name to the port without getting a list of all processes and their ports). Is there a better method to get this functionality? Thank you, Ganesh Kumar Quote Link to comment
Tim_S Posted December 23, 2011 Report Share Posted December 23, 2011 You can, when creating a listener, give the port number a string name. The TCP connect primitive can accept the string name as the port number. Tim Quote Link to comment
asbo Posted December 23, 2011 Report Share Posted December 23, 2011 If you've gotten the iphlpapi.dll method working robustly and it works on all the versions of Windows you need, I'd say this is the ideal way. There problem isn't a significant amount of overhead in getting the entirel The netstat method is much worse (in my eyes) because it includes a separate process call of which you have to parse the output. If you have development control of the applications in question, Tim_S's idea is excellent. Quote Link to comment
ganeshkumar1989 Posted December 26, 2011 Author Report Share Posted December 26, 2011 (edited) You can, when creating a listener, give the port number a string name. The TCP connect primitive can accept the string name as the port number.Tim Tim, Thank you for your reply. The requirement is, given any Exe name, the VI that we develop must be able find out the port number that the Exe is using. Hence the solution to this problem must be independent of any other appication. The reason why we are looking for the port number is that we need to open the application reference. If you've gotten the iphlpapi.dll method working robustly and it works on all the versions of Windows you need, I'd say this is the ideal way. V I Engineering, Inc., Thanks for your reply. The option of using iphlpapi.dll may be a good one. But the functions may go unsupported in the newer versions of Windows. For example, AllocateAndGetTcpExTableFromStack method in this DLL is not availalbe from Windows Vista. That is the reason why we will have to re-think. I have one more question. In case, for an application, if the web server is also enabled, we would get 2 port numbers for the same application (when we try to find the ports used by the application using any method like netstat). Assuming we have no control over the application being developed, how do we find out as to which port corresponds to the Web Server and which one corresponds to VI server? Thank you, Ganesh Kumar Edited December 26, 2011 by ganeshkumar1989 Quote Link to comment
Tim_S Posted December 27, 2011 Report Share Posted December 27, 2011 Obsolescence is always going to happen. Microsoft support legacy code for a very long time (there are still DOS programs that work in Windows), so I don't see why you'd be concerned about such. Changes that could impact you (such as the UAC) are outside of what you can control or plan for. Quote Link to comment
asbo Posted December 27, 2011 Report Share Posted December 27, 2011 V I Engineering, Inc., Thanks for your reply. The option of using iphlpapi.dll may be a good one. But the functions may go unsupported in the newer versions of Windows. For example, AllocateAndGetTcpExTableFromStack method in this DLL is not availalbe from Windows Vista. That is the reason why we will have to re-think. I agree with Tim_S. It's unclear to me, though; are you using the Allocate...Stack function or is this just an example of deprecation? If the former, what is Microsoft's official recommendation for its successor? In any case, if all of your functionality works on all the platforms you want to support *right now* then I'd write the code and call it a day. No point in coding circles around a problem which may never come to be. I have one more question. In case, for an application, if the web server is also enabled, we would get 2 port numbers for the same application (when we try to find the ports used by the application using any method like netstat). Assuming we have no control over the application being developed, how do we find out as to which port corresponds to the Web Server and which one corresponds to VI server? To identify a Web Server port, issue a HEAD request and see if you get a valid HTTP response. There may be a built-in way to do this, but this is what came to mind. To identify a VI server, use the Open Application Reference node and see if the node does not return an error. If you cannot test from LabVIEW, I don't know what else you can do. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.