Winsock problem: My computer has two IPs!!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Winsock problem: My computer has two IPs!!!

Hello,

I am trying to send emails from visual basic (vb6 sp6). The problem is that my pc has two ip addresses (one ip is for a control network and the other one is for the internet connection) and the winsock is using the wrong one (the one for the control network). How can I force the winsock control to use the internet ip address in order to avoid connection problems? I am using the mswinsck.ocx control.

here is my code:

mvarWinsock.RemoteHost = mvarSmtpServer
mvarWinsock.RemotePort = 25
mvarWinsock.Protocol = sckTCPProtocol
mvarWinsock.Connect

When i take a look at the LocalIP property i can see that it is set to the control network ip.

can someone help me please?

Thanks in advance.

John

Comments

  • luckyumerluckyumer Posts: 21Member
    Hey Dear,
    If you would connect to a remote server in a LAN, your local LAN IP address will be used and
    if the remote server is on the Internet,
    your Internet IP will be used
    Umer Saleem
    Lahore - Pakistan
    [email protected]
    Mob: 0092 321 4257504

  • lionblionb Posts: 1,688Member ✭✭
    [b][red]This message was edited by lionb at 2005-9-30 4:57:26[/red][/b][hr]
    : Hello,
    :
    : I am trying to send emails from visual basic (vb6 sp6). The problem is that my pc has two ip addresses (one ip is for a control network and the other one is for the internet connection) and the winsock is using the wrong one (the one for the control network). How can I force the winsock control to use the internet ip address in order to avoid connection problems? I am using the mswinsck.ocx control.
    :
    : here is my code:
    :
    : mvarWinsock.RemoteHost = mvarSmtpServer
    [blue]To specify a remote host, you can use either the IP address (ex: "121.111.1.1") or the computer's "friendly" name, as shown here.
    [b]mvarWinsock.RemoteHost = "121.111.1.1"[/b]
    or
    [b]mvarWinsock.RemoteHost = "RemoteComputerName"[/b]
    [/blue]
    : mvarWinsock.RemotePort = 25
    : mvarWinsock.Protocol = sckTCPProtocol
    : mvarWinsock.Connect
    :
    : When i take a look at the LocalIP property i can see that it is set to the control network ip.
    :
    : can someone help me please?
    :
    : Thanks in advance.
    :
    : John
    :



  • John VargasJohn Vargas Posts: 34Member
    Hi,

    I am using the IP for the SMTP server and the port is 25 (for SMTP).

    Let me give you an example:

    The IP #1 (used for the control LAN) is 192.12.1.16 and the IP #2 used for the internet is the 10.35.1.85. The SMPT server IP is 10.35.1.71, then:

    winsock1.RemoteHost="10.35.1.71"
    winsock1.RemotePort=25
    winsock1.Connect

    but when I read the LocalIP property after the Connect command it has the value "192.12.1.16" . If it were pointing to the right network (Internet) it should be set to "10.35.1.85" instead.

    I can not set the LocalIP property directly because it is read only, nor I can use the Bind method because I am using TCP protocol.

    Any other idea please?

    Thanks...John

    : [b][red]This message was edited by lionb at 2005-9-30 4:57:26[/red][/b][hr]
    : : Hello,
    : :
    : : I am trying to send emails from visual basic (vb6 sp6). The problem is that my pc has two ip addresses (one ip is for a control network and the other one is for the internet connection) and the winsock is using the wrong one (the one for the control network). How can I force the winsock control to use the internet ip address in order to avoid connection problems? I am using the mswinsck.ocx control.
    : :
    : : here is my code:
    : :
    : : mvarWinsock.RemoteHost = mvarSmtpServer
    : [blue]To specify a remote host, you can use either the IP address (ex: "121.111.1.1") or the computer's "friendly" name, as shown here.
    : [b]mvarWinsock.RemoteHost = "121.111.1.1"[/b]
    : or
    : [b]mvarWinsock.RemoteHost = "RemoteComputerName"[/b]
    : [/blue]
    : : mvarWinsock.RemotePort = 25
    : : mvarWinsock.Protocol = sckTCPProtocol
    : : mvarWinsock.Connect
    : :
    : : When i take a look at the LocalIP property i can see that it is set to the control network ip.
    : :
    : : can someone help me please?
    : :
    : : Thanks in advance.
    : :
    : : John
    : :
    :
    :
    :
    :

Sign In or Register to comment.