|
-
Sep 21st, 2007, 12:30 AM
#1
Thread Starter
Lively Member
Winsock: How to receive data when you cant bind to a port?
Im using a winsock control in my application to read data that comes in on a specific IP. The remote IP is static, as is the remote port. However, it binds to a different local port every time. Is there a way to 'override' this issue? Is there a way in VB6 to allow the incoming data to randomly select the portit wants, and then have the application bind to it?
Im using the following code, but the 'Bind' value cannot be predefined. Is there a way I could allow the application to randomize the choice of local ports? Sometimes it connects to port 1045, sometimes 1046, or 1048 etc.
With Winsock1
.RemoteHost = "xxx.xxx.xxx.xxx"
.RemotePort = 1809
.Bind 1045
End With
Thanks
-
Sep 21st, 2007, 05:47 AM
#2
Re: Winsock: How to receive data when you cant bind to a port?
How do you determine what port it is binding to now?
-
Sep 21st, 2007, 08:30 AM
#3
Thread Starter
Lively Member
Re: Winsock: How to receive data when you cant bind to a port?
Hi Hack..
I cant determine the port. However, the data is also used by another application. And when running that application, i have used port sniffer to see that the incoming port is different every time. And when that application is running, I cannot use my winsock control to bind to that port, since its already in use.
Is there a way to use that port while its already in use, so that I can import that data stream into my own application as well?
-
Sep 21st, 2007, 01:33 PM
#4
Re: Winsock: How to receive data when you cant bind to a port?
Some other application is reading the port? Then you can't get the data from the port, you have to get it from the application (which has to send it to you). There's no "splitter" for IP ports.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Oct 1st, 2007, 11:02 AM
#5
Re: Winsock: How to receive data when you cant bind to a port?
It is possible to specify a value for LocalPort on a TCP client socket, but it is generally undesireable and causes problems.
The real question is why on Earth you'd want to? TCP clients are normally assigned a port from the ephemeral pool automatically by TCP. This should have no impact on sucessfully using the resulting connection. This is just how TCP works.
What are you trying to do? Your comments almost seem to suggest you want to try to "tap into" another application's TCP connection.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|