Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8173801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:17:22+00:00 2026-06-06T22:17:22+00:00

Long time ago I made a socket based server application using the principle of

  • 0

Long time ago I made a socket based server application using the principle of this piece of code (IP address and port constans are only for testing):

   ...
   _mainSocket = new Socket(AddressFamily.InterNetwork, 
                            SocketType.Stream, ProtocolType.Tcp);

   _mainSocket.SetSocketOption(SocketOptionLevel.IP, 
                               SocketOptionName.ReuseAddress, 1);

   IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("192.168.1.103"), 77);

   _mainSocket.Bind(endPoint);

   _mainSocket.Listen(5);

   _mainSocket.BeginAccept(new AsyncCallback(OnClientConnect), null);
   ...

It has worked well for years, until recently, when a customer installed the the service on a Windows Server 2008 machine and tried to connect to it from antoher network (i.e. through one or more routers).

Surprisingly this was not possible!

Further analysis revealed that the root cause was TTL (Time-To-Live parameter in IP packet headers) being set to 1 in all reply packets from my service, effectively causing them to be to be dropped at the first router they meet.

The funny thing is, that if I remove the SetSocketOption(…) call, TTL gets back to the ususal 128!

This odd behavior seems only to be the case with Windows Server 2008. Both Windows XP and Windows 7 stays on TTL=128 as I would expect it to do. I see no reason at all why TTL should be changed with the “ReuseAddress” option. Can anyone explain?

I can also get TTL back to 128 by adding a second SetSocketOption(…) call after the first one:

_MainSocket.SetSocketOption( SocketOptionLevel.IP,
                             SocketOptionName.DontRoute, 0).

This effectively neutralizes the unwanted side effect of the first SetSocketOption(..) call…

Please tell me what I don’t seem to understand in this matter?

Martin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:17:24+00:00Added an answer on June 6, 2026 at 10:17 pm

    This blurb posted on the MSDN page for SocketOptionName seems somewhat illuminating, although I haven’t confirmed it:

    Misunderstanding when reading source code of .NET Framework with .NET
    Reflector Use Red Gate’s .NET Reflector to decode class Socket in .NET
    Framework v2.0…

    …

    Why that is ReuseAddress instead of IpTimeToLive?

    In fact:

    SocketOptionName.IpTimeToLive == SocketOptionName.ReuseAddress == 4

    If this is somehow the case, that would explain why the TTL was getting set to 1 — that’s the value you’re passing in for ReuseAddress.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compile a code that I have from long time ago using
A long time ago a friend made this for me: $(.rnd1).click(function(){ $(*).click(function (event) {
So i created a web site a long time ago using a designer alot
I remember that I've seen this effect long time ago on a website. It
I had a website made for me a long time ago, and the programmer
This is the problem I ran into long time ago. I thought I may
My site: FIFA Encyclopedia A long time ago I made some big changes and
A long time ago I took over maintenance of a web based content management
I read a long time ago about a rule that using an object we
Should have asked someone this a long time ago. What is the best way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.