HighTechTalks DotNet Forums  

Bizarre build-and-address-dependent Socket problem

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss Bizarre build-and-address-dependent Socket problem in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Bizarre build-and-address-dependent Socket problem - 04-06-2006 , 01:26 PM






I have a client-server application that is acting rather strangely.

There are two programs, client and server.
There are two builds, release and debug.
There are two ways to specify the server address: loopback address and
internet address.

Now consider that every combination of builds, programs and addresses
work - unless the server is the release build and the client connects
to it with a full internet address. That is, if either release or
debug client connects to the release server using the server's internet
address (format 255.255.255.255), the connect attempt will encounter a
timeout exception. Realize that the debug server works flawlessly.

The debug and release builds differed by:

1. Debug builds define the DEBUG symbol
2. Debug builds create pdbs.
3. Debug builds do not optimize code.

I changed my builds so that release and debug are identical in these
three ways, and I don't see any other ways in which the builds can be
made more identical. The changes made no difference, and the timeouts
continued. I regularly revisit the scenarios that work to ensure that
they still work as I fool around with this stuff. For the record,
there have been numerous rebuilds of the entire solution.

I also run this both on a single machine and between two machines on a
LAN. Using LAN addresses works identically to using a full
internet-visible address (debug server can be connected to, release
server cannot).

My next step was to create a dead-simple client and server that only
exist to connect to each other using the same code that I use in my
main application. Here is the pertinent code in C#:

CLIENT: (lacking the specific internet address that I use in the code)

System.Net.IPHostEntry heHostEntry =
System.Net.Dns.Resolve("xxx.xxx.xxx.xxx");

Socket sSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
sSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.KeepAlive, 1);
sSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.NoDelay, 1);
sSocket.Blocking = true;
sSocket.Connect(new System.Net.IPEndPoint(heHostEntry.AddressList[0],
1000));
MessageBox.Show("Done Client");

SERVER:

Socket sSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
sSocket.Blocking = true;
sSocket.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Any,
1000));
sSocket.Listen(10);
sSocket.Accept();
MessageBox.Show("Done Server");

Unhappily, my little brain-dead applications worked just fine in both
debug and release builds. As a result, this has me completely stumped.

I've been playing with this all day and can't seem to find what it is
that is plaguing my release build server (even when it appears to be
built identically to a debug build). Comments would be appreciated.

I should add that Visual Studio 2005 was installed and removed from
this machine. Software of note:

..NET Framework 1.0, 1.1, 2.0
..NET Framework SDK 1.0a, 1.1
Visual Studio 2002 upgraded with Visual C# .NET 2003

Thanks for any help.

JB


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.