Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Controlling which port to download from

Posted on 2016-08-16
4
Medium Priority
?
86 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

972 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