Choose IP

  • Thread starter Thread starter Nattydreadlock
  • Start date Start date
N

Nattydreadlock

Hello,

I have a little problem here.
I have a server which has multiple IP addresses. I'm writing a program
which connects to a webservice but at run-time I need to decide which
IP to use. Does anyone has an idea about how you can programmatically
set your IP-address in .NET , c# or VB

Greetings
Kenneth
 
Hello, Nattydreadlock!

N> I have a little problem here.
N> I have a server which has multiple IP addresses. I'm writing a program
N> which connects to a webservice but at run-time I need to decide which
N> IP to use. Does anyone has an idea about how you can programmatically
N> set your IP-address in .NET , c# or VB

before calling connect you have to bind your socket to specific IP address.
The sample is like this

Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Bind(new IPEndPoint(ipAddress, somePort));
s.Connect("somewhere", someOtherPort);

The connection will be established from ipAddress address and somePort port

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Hi,

thnx for the answer.

But the problem is that calling a webservice is totally encapsulated in
Visual Studio.NET 2005.

So where can I change the socket over which it will connect?
Where in code should I make these changes?

Greetings

Kenneth
 
Somone had the same problem today on another newsgroup. This is the answer:

The proxy class generated after adding the service as web reference has a
property called Url, where you can set the location of the service. You'd
also have to set the url behavior to dynamic
 
Hi,

I think we are not on the same line for this solution. I'll explain the
problem again:

I have a server which has 2 IP addresses. From this server I need to
call a webservice.
This webservice checks on IP address to see if you are calling from an
allowed IP address.
The situation is like this:

The service accepts for each login just one IP address. What I want to
do is to be able to log in with the same program for 2 accounts.
Thus I have to make the service think that when I log in with account 1
my IP address is 62.62.62.62 for example.
When I log in with account two though the service should think that my
IP address is 100.100.100.100 for example.

My server has 2 fixed IP-addresses, so I need to be able to tell the
server from which IP he should send the request.

I hope you understand the problem better.

Thanx

Kenneth
 
Sorry,

I still made a little mistake here.
I'm not actually calling a webservice, I'm connecting over a secure
channel
something like this :


Dim options As New SecurityOptions(SecureProtocol.Ssl3)
options.AllowedAlgorithms = SslAlgorithms.RSA_AES_128_SHA Or
SslAlgorithms.RSA_AES_256_SHA Or SslAlgorithms.SECURE_CIPHERS
options.VerificationType = CredentialVerification.Manual
options.Verifier = New CertVerifyEventHandler(AddressOf OnVerify)
Me.socket = New SecureSocket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp, options)
Me.endpoint = New
IPEndPoint(Dns.GetHostEntry(Me.server).AddressList(0), Me.port)


Me.socket.Connect(endpoint)
 
Hello,

I'm using this to connect over an SSL-channel. I think you don't
understand my question here.
I know at design TO which IP I need to connect. At run time though I
want to be able to decide FROM which IP I need to connect.

My own server has two IP's coupled to it and I need to be able to say:
send a request from IP1 or IP2

Greetings,
Kenneth
 
Back
Top