Error 10048

Topics: User Forum
Feb 8, 2008 at 1:10 PM

I have just started looking at indexus shared cache - I have multiple applications running in different locations which need to share some small items of data. I have downloaded version, and made a simple test program.

If I call "CacheUtil.Add(key, myobject)" many times (eg. 10000 times) in a tight loop, I get this error after a short time:

Error Code 10048
"Normalt må en socket-adresse (protokol/netværksadresse/port) kun bruges én gang"
Normally may a socket-address (protocal/network address/port) only be used one time

What causes this, and how do I fix it? (Do I just ensure I avoid call CacheUtil.Add too many times too quickly?)


Feb 9, 2008 at 10:14 AM
Edited Feb 9, 2008 at 1:57 PM
Hi Peter,

thanks for reporting. Please consider the following issues:
  • Error Code 10048 happens only if you try to reuse the same port twice. e.g. When you start the server twice you will get see this error.
  • We do not suggest to use CacheUtil.Add() at all, because you have to develop the whole distribution around it by yourself. We suggest to use only the provider like we its used in the test application or even notify app. is using it. If you consider to use CacheUtil.XXX directly please consider you will have a lot of additional work to do which is given by the provider.
  • In the test application we have provided the 2 cases with 10000 items, please try to run them and let us know if you still face with this problem
    • 1 kb
    • 100 kb

Are you able to provide us some code once you have changed it and you make usage of the provider? Feel free to post it here or to send it to sharedcache[AT]indexus[DOT]net

thanks roni

Feb 9, 2008 at 8:09 PM
Hi, thanks for taking the time to reply and explain about the problem.

I have tried to change my program to use the provider as you suggest, but I still see the error occur. I was using CacheUtil as I saw that in a sample on the website (at

Anyway, here is my program which uses IndexusDistributionCache.SharedCache.
The program starts 25 threads, each of which runs a loop 100 times putting and getting a "Person" object to the cache. (The Person object is unimportant, holding my name for example).
Following the program is the app.config I use. I was unsure about many settings, but have tried to copy bits and pieces from various of your samples.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

using MergeSystem.Indexus.WinServiceCommon;
using MergeSystem.Indexus.WinServiceCommon.Provider.Cache;
using PRIORITY = MergeSystem.Indexus.WinServiceCommon.IndexusMessage.CacheItemPriority;

using SharedDataObjects;

namespace TestIndexusConsoleApp
/// <summary>
/// A test program using the Indexus cache.
/// </summary>
public class Program
/// <summary>
/// Entry point.
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args)
Console.Out.WriteLine("Main: Start PUT program");
Program p = new Program();
catch (Exception ex)
Console.Out.WriteLine("Main: EXCEPTION " + ex.Message);
Console.Out.WriteLine("Main: End PUT program (press enter to exit)");

/// <summary>
/// Do a small test using the cache.
/// Start some threads which each put and get an object to/from the cache in a loop.
/// </summary>
public void DoIt()
Console.Out.WriteLine("DoIt: Starting PUT threads (press enter to start) ...");

// Initialise some threads
int THREAD_COUNT = 25; // How many threads to start

Thread[] putThreads = new ThreadTHREAD_COUNT;
for (int i = 0; i < THREAD_COUNT; i++)
// Instantiate and start up the "put" threads:
PutThread putter = new PutThread();
putter.ThreadNum = i;

ThreadStart ts = new ThreadStart(putter.Put);
Thread thread = new Thread(ts);
putThreadsi = thread;


// Wait for all the threads to finish, so we can display a "completed" message
for (int i = 0; i < THREAD_COUNT; i++)

Console.Out.WriteLine("DoIt: PUT threads completed");

/// <summary>
/// This class is intended to be used as a "thread". It puts an object into the cache, and obtains
/// the object from the cache again, many times in a loop.
/// </summary>
public class PutThread
private Random r = new Random((int)DateTime.Now.Ticks);

/// <summary>
/// Gets and sets a simple identifier for the thread.
/// </summary>
public int ThreadNum { get; set; }

/// <summary>
/// The "thread method". This method contains a loop which uses the cache for storing and
/// fetching an object.
/// </summary>
public void Put()
// Random start up delay
int mss = r.Next(1000, 10000);
Console.Out.WriteLine("PutThread: start " + ThreadNum + " (delay=" + mss + ")");


for (int i = 0; i < NUMCACHEREQUESTS; i++)
Console.Out.WriteLine("PutThread: Put Person " + i + " (" + ThreadNum + ")");

Person person = new Person();
person.FirstName = "Peter Alan";
person.LastName = "Kirk";
person.DateOfBirth = new DateTime(2000, 12, 31);

string key = "Indexus Person Cache";
IndexusDistributionCache.SharedCache.Add(key, person);

int ms = 50;

// Get the object again:
Person gotten = IndexusDistributionCache.SharedCache.Get<Person>(key);

int ms1 = 50;
catch (Exception ex)
Console.Out.WriteLine("Error in thread " + ThreadNum + ":" + ex.Message);
Console.Out.WriteLine("PutThread: end " + ThreadNum);

<?xml version="1.0" encoding="utf-8" ?>

<section name="indexusNetSharedCache" type="MergeSystem.Indexus.WinServiceCommon.Configuration.Client.IndexusProviderSection, MergeSystem.Indexus.WinServiceCommon"/>

<!--Should information be logged-->
<add key="LoggingEnable" value= "1" />

<!--Location of Cache Service-->
<add key="ServiceCacheIpAddress" value= "" />

<!--Location of Cache Service, the port number-->
<add key="ServiceCacheIpPort" value= "48888" />

<!--UDP port number-->
<add key="ServiceCacheUdpPort" value= "48889" />

<!--If the service is running in debug mode-->
<add key="ServiceCacheDebugMode" value= "1" />

<!--Maximum read timeout.-->
<add key="ServiceCacheReadTimeOut" value= "1000" />

<indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
<add key="SrvZh03" ipaddress="" port="48888" />
type="MergeSystem.Indexus.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, MergeSystem.Indexus.WinServiceCommon"


Feb 9, 2008 at 9:50 PM
hi peter,

can you drop me this sample to : sharedcache[AT]indexus[DOT]net ? it will be easier to have a close look on it.

thanks roni
Feb 12, 2008 at 8:53 PM
hi peter, please have a close look at latest pre-release: pre_release_2.0.0.140 - pre_release_2.0.0.145 . there is a option 410 which does exaclty what you tried to do. let us know if you have still problems to run it.
Feb 13, 2008 at 8:55 AM
Hi - thanks for the notification. Unfortunately I am working on a more pressing issue for us right now. But I will return to "shared cache" in some days. Thanks for your help.