Solved

Controlling which port to download from

Posted on 2016-08-16
4
59 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

706 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

20 Experts available now in Live!

Get 1:1 Help Now