Solved

Controlling which port to download from

Posted on 2016-08-16
4
71 Views
Last Modified: 2016-08-24
Using vb6 winsock

On server IP,   111.222.333.444
Program A.exe keeps listening to port 1234

On Client from any IP,
Program B.exe uses a random port, sends request to IP 111.222.333.444  (server port 1234)

I need to control the port number which Program B.exe uses

Any Idea
Thanks
0
Comment
Question by:saljas
  • 2
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 41758206
If you are using the winsock control, then set the .LocalPort property....
source: https://msdn.microsoft.com/en-us/library/aa228137%28v=vs.60%29.aspx

So many other applications may happen to  choose the same port on your client that you may have a port already in use and cause it not to work. That is why the local port just randomly opens one, I guess.

You might have your client app take a command-line argument that specifies the local port number and possibly the remote one, to allow it to be called with maximum flexibility.
Example
      programb.exe /L=7891

and/or

      programb.exe --localport=7891

Open in new window

0
 

Author Comment

by:saljas
ID: 41763413
SStory
Many thanks for your help.
I think LocalPort property is good.
Do you know a way to know a windows app to tell which port is being used - just to make sure LocalPort is doing the job?
0
 
LVL 25

Expert Comment

by:SStory
ID: 41764629
I guess English isn't your first language?  Are you asking if I know how to tell what port a Windows app is using or if I know how to tell a Windows app which port to use?  Detect? or Force?  Which are you asking?

TCPVIEW by SysInternals, which was bought by MIcrosoft can tell you the ports in use--though I don't recall if it shows the related application or not.  Maybe also with netstat.exe or nbtstat
0
 

Author Comment

by:saljas
ID: 41769072
Sorry

Bad line Is (Do you know a way to know a windows app to tell which port is being used )
Good line is (Do you know a windows app to tell which port is being used )

and you already answered it - thanks
everybody is using  TCPVIEW and I am using NetLimiter which gives every thing.

I am going to post another question regarding the Close_wait and Fin_Wait I will be glad to have your openion.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now