Solved

Controlling which port to download from

Posted on 2016-08-16
4
76 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

710 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