Well Im making this in VB6, is it possible to Listen UDP for incoming information and have a TCP socket connect through the same port? Isent it possible if your Local Port to the TCP is a different port then the remote port you are connecting to?
For Example
The UDP socket Binds and Listen on Port 80
The TCP port binds itself to a High port like 65000
The TCP makes a connect request to some foreign ip on port 80
Is this something close that IE does like when you netstat, which allows you to connect to multiple port 80s on different web servers like Google and yahoo?
EDIT: Reading over Beej's Network guide, It make work if I BIND the socket with Windows API/Winsock control correct?
if you do not bind the port does it assume the localport = the remoteport which is the reason why a error is triggered?
if so what is the safest way to bind a TCP port to a unused local port?
xander_tan
April 15th, 2009, 01:15 AM
Well Im making this in VB6, is it possible to Listen UDP for incoming information and have a TCP socket connect through the same port? Isent it possible if your Local Port to the TCP is a different port then the remote port you are connecting to?
For Example
The UDP socket Binds and Listen on Port 80
The TCP port binds itself to a High port like 65000
The TCP makes a connect request to some foreign ip on port 80
Is this something close that IE does like when you netstat, which allows you to connect to multiple port 80s on different web servers like Google and yahoo?
EDIT: Reading over Beej's Network guide, It make work if I BIND the socket with Windows API/Winsock control correct?
if you do not bind the port does it assume the localport = the remoteport which is the reason why a error is triggered?
if so what is the safest way to bind a TCP port to a unused local port?
If an application bind a port number, any other application will not be able to bind that particular port number, i.e. if you install Microsoft IIS using port 80, you can't install Apache using port 80. What you can do is to have (for example) Apache to use port 80 and Microsoft IIS using port 81, and then you http_forward or load balance the request from Apache to Microsoft IIS. I believe that the condition applies to both UDP and TCP connections, because the different between UDP and TCP is only the protocol. To have two applications, one with UDP and another with TCP to bind the same port number is not possible. And of course, you can't connect to UDP server using TCP connection. It is like connection to tftp server using ftp client.
If you open google.com using port 80, it doesn't mean that your client browser is using port 80, it will use a random port within a certain range. So, you can have a UDP application bind port 80, while you are connecting to google.com using a web browser. Anyway, any web browser should not use the reserved port number, e.g. 21, 22, 23, 80, etc. When you are connecting to many web servers, i.e. to google, yahoo, microsoft, codeguru, etc, your web browser is using different port number, which is certainly not number 80.
Unfortunately, it's been a long time I don't use Winsock2. It is true that you have to bind the socket to a port number to let it work. Whether or not it will assume the same port number for local and remote port, I am not so sure. The safest way is to look for an unused port number.
AgentSmithers
April 15th, 2009, 11:23 AM
If an application bind a port number, any other application will not be able to bind that particular port number, i.e. if you install Microsoft IIS using port 80, you can't install Apache using port 80. What you can do is to have (for example) Apache to use port 80 and Microsoft IIS using port 81, and then you http_forward or load balance the request from Apache to Microsoft IIS. I believe that the condition applies to both UDP and TCP connections, because the different between UDP and TCP is only the protocol. To have two applications, one with UDP and another with TCP to bind the same port number is not possible. And of course, you can't connect to UDP server using TCP connection. It is like connection to tftp server using ftp client.
If you open google.com using port 80, it doesn't mean that your client browser is using port 80, it will use a random port within a certain range. So, you can have a UDP application bind port 80, while you are connecting to google.com using a web browser. Anyway, any web browser should not use the reserved port number, e.g. 21, 22, 23, 80, etc. When you are connecting to many web servers, i.e. to google, yahoo, microsoft, codeguru, etc, your web browser is using different port number, which is certainly not number 80.
Unfortunately, it's been a long time I don't use Winsock2. It is true that you have to bind the socket to a port number to let it work. Whether or not it will assume the same port number for local and remote port, I am not so sure. The safest way is to look for an unused port number.
That is what I very much Figured, Now just gotta find out how to bind them, Its got to assume the Localport is the same as the remote port.
xander_tan
April 15th, 2009, 07:09 PM
That is what I very much Figured, Now just gotta find out how to bind them, Its got to assume the Localport is the same as the remote port.
I found this article: http://www.15seconds.com/Issue/010820.htm
At the client application, it only declares the remote port:
Winsock1.RemotePort = 1007
At the server application, it only declares the local port:
Socket(iSockets).LocalPort = 1007
I believe that the client application will automatically get a random, unused port number.
AgentSmithers
April 16th, 2009, 11:31 AM
I dont belive thats correct 100%, In my case I have a web server running and when I try to Remote Port on port 80 it says Ports in use.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.