Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Controlling which port to download from

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

Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

722 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