Hi
I’m aware that same Questions have been asked in the past and I’m sorry for double posting but I didn’t quite find a solution in the threads.
I’m using the HomeOSGadgeteerLibrary which now runs on my FEZ Raptor. The Problem is that when calling the Accept Method my program just hangs forever. So what I tried is making a Thread and just join it after a timespan so I could reset the whole things, but I’m not very successful in doing this.
Is there a solution to my Problem?
Here’s the relevant code and the major issue is on line 12
```cs
protected void ProcessRequest()
{
// accept an incoming connection request and once we have one, spawn a new thread to accept more
bool newThread = false;
Socket clientSocket = null;
Responder responder = null;
while (IsRunning && !newThread)
{
try
{
// process incoming request
Thread connectionThread = new Thread(() => { clientSocket = LocalServer.Accept(); }); //This call just hangs forever!! Thats why I put it into a thread!
connectionThread.Start();
connectionThread.Join(10000);
if (clientSocket == null)
{
Debug.Print("Resetting...");
//HOW?
}
else
{
Debug.Print("Got a connection!");
clientSocket.ReceiveTimeout = Timeout;
clientSocket.SendTimeout = Timeout;
// parse message an create an object containing parsed data
responder = new Responder();
responder.ClientEndpoint = clientSocket.RemoteEndPoint.ToString();
responder.ClientSocket = clientSocket;
Debug.Print("Accepted connection from " + responder.ClientEndpoint);
Debug.Print("Thread: " + Thread.CurrentThread.ManagedThreadId + " accepted a socket!");
}
Thread t = new Thread(new ThreadStart(ProcessRequest));
t.Start();
newThread = true;
}
catch
{
if (clientSocket != null)
{
try
{
clientSocket.Close();
}
catch
{
}
}
}
}
//actual processing of the request
...
}
I appreciate your help and hope we can find a solution to my problem