473,320 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

IPHostEntry.AddressList Property (XP vs Vista)

Hi All -

Using Visual Studio 2005 Pro...

I'm going to ask a question about some code I inherited. I'm trying
to learn how it works so please bear with me if my question doesn't
make sense. I have a program that acts as a socket server - a
middleman between a fortran dll and several client apps. Runs fine on
XP. Threw it on a Vista machine the other day and it kept bombing
out.

After a bit of debugging the code on the Vista machine and the XP
machine, I discovered the difference and I seem to have solved my
problem, though I don't really understand it.

This server waits for a connection and then uses asychronous
operations to
accept the connection, get data from the connected client,
performs the requested functions (calls fortran.DLL) and
returns output to the client.
It then disconnects from the client and waits for another client.

----------------------------------------------------------------------------------------------------------------------

Public Shared Sub Main()

'Get port from registry
Dim iPort As Int16 = My.Settings.port

'Make seperate thread for system tray icon
Dim thrCtl As New BackgroundWorker
AddHandler thrCtl.DoWork, AddressOf Notify_Handler

thrCtl.RunWorkerAsync()

' Data buffer for incoming data.
Dim bytes() As Byte = New [Byte](1023) {}

' Establish the local endpoint for the socket.
Dim ipHostInfo As IPHostEntry = Dns.GetHostEntry("localhost")
Dim ipAddress As IPAddress = ipHostInfo.AddressList(0)
Dim localEndPoint As New IPEndPoint(ipAddress, iPort)

' Create a TCP/IP socket.
Dim listener As New Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp)

' Bind the socket to the local endpoint and listen for
incoming connections.
listener.Bind(localEndPoint)
listener.Listen(100)

more code
more code
more code

----------------------------------------------------------------------------------------------------------------------

My question refers to the line:

Dim ipAddress As IPAddress = ipHostInfo.AddressList(0)

In XP, so far as I can tell, the .AddressList returned is always
length = 1 (no matter which machine I run it on), so subscript 0
always contains the information I need to continue. However, on my
Vista machine (one data point, I know, I know), the .AddressList
returned is length = 2, and the subscript 1 contains the information I
need to continue.

So to make this run in Vista I just changed a single character, the
zero to a one, and everything works.

Dim ipAddress As IPAddress = ipHostInfo.AddressList(1)

So I'm not really even sure what question to ask here. I guess, why
might I get length 1, and when I do, how can I figure out which one
I need? Try a novice in this particular area of VB.NET. MSDN docs
are pretty confusing. I'm not sure if this is even an XP vs Vista
issue, or maybe it's not OS dependent and I'm missing some other key
detail.

Thanks in advance for any help.
Dec 26 '07 #1
0 1501

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: techprot-google04 | last post by:
I've found tons of sample code on pinging - but all start with the host name, resolve the ip address and do the ping. Does anyone have any sample code that does a ping from an ip address alone?...
0
by: Richy | last post by:
Hi, I am running VB Express 2005 and have been developing an application fine under Windows XP, but now I have switched to WIndows Vista I am getting strange behaviour with the PropertyGrid...
5
by: Bob | last post by:
Hi, I have some code that sets up an asynchronous server. It is working fine on my XP machines but I can't get it to work on Vista. Actually, it "works: in that it runs but when I try to connect...
5
by: Wayne | last post by:
Several of my Access 2003 databases are exhibiting the same problem under Windows Vista. Charts in forms are not showing any data. Reports are not affected. Charts in reports display as they...
0
by: Valerie Hough | last post by:
My app currently runs C#, .NET v2.0 on Windows Xp/Windows Server 2003, using asynchronous socket communication. I set up my server socket: Socket s = new Socket( AddressFamily.InterNetwork,...
2
by: mindspring | last post by:
A pc that was created in MS office xp's Access 2002 has been working fine on a windows vista Ultimate pc that has MS OFfice Vista Edition. But all of the sudden it stopped working and gives this...
10
by: Arno R | last post by:
Hi all, So I bought a new laptop 10 days ago to test my apps with Vista. (home premium) Apparently Office 2007 is pre-installed. (a time limited but complete test version, no SP1) So I take the...
4
by: jehugaleahsa | last post by:
Hello: We are working in VS 2005, C# with Team System. We have a text box that is bound to a business object property. We have some code behind that will populate the text box when they choose a...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.