Hi all, I've been working on an .net application which starts different instances of a class, each one contains a main thread (it's a TcpListener). The application so far in the development PC (WinXP SP3 Pro, VS2008, .net Framework 3.5 SP1) works very nice, but when i move it to the destination machine (Windows Server 2003 R2, .net Framework 3.5 SP1) it just doesn´t works. I've tracked the error to the main thread in each one of the instances, and is caused because i read the Parameters passed to the thread itself! Someone has an idea about what could i've been missing? Thanks in advance.
Thread initialization:
Thread itself
Thread initialization:
Code:
ListeningThread = new Thread(new ParameterizedThreadStart(ServerThread));
ListeningThread.Name = "ListeningThread";
ListeningThread.IsBackground = true;
ThreadList.Add(ListeningThread);
myLog.Add("Thread de servidor lanzado");
string Data = ListeningIP.ToString() + ":" + Port.ToString();
ListeningThread.Start((object)Data);
Code:
public void ServerThread(object EndPoint) //EndPoint = IP:Puerto (en string)
{
// Crea un socket TCP/IP (IPv4) y escucha por conexiones.
try
{
string Parametros = (string)EndPoint;
myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() + "}Datos recibidos en el thread: " + (string)EndPoint);
string[] Datos = Parametros.Split(':');
if (Datos.Length < 2)
throw new Exception("Error en parametros");
System.Net.IPAddress LocalIP = System.Net.IPAddress.Parse(Datos[0]);
int LocalPort = Int32.Parse(Datos[1]);
myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() + "}--Entrando a Thread de Servidor--");
myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() + "}--IP para escuchar: " + LocalIP.ToString() + ":" + LocalPort.ToString());
TcpListener listener = new TcpListener(LocalIP, LocalPort);
myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() + "} Datos Listener" + listener.LocalEndpoint.ToString());
listener.Start();
.....
Comment