That old black magic > Sockets!

I’m Curious about this issue…

I have been trying to create two applications. One application is for my Fez.Spider and the other is a Windows TaskTray application.
I am using UDP sockets and I can successfully sent text messages to the Spider from the TaskTray app. However, I have NOT been able
to figure out how to receive messages from the Spider.

I am using a NETGEAR WNCE2001 (WiFi Bridge) connected to the Spider ethernet module J11D.
(I am assuming that a ‘WiFi bridge’ is two way communication) Am I wrong?

In my quest to solve my failures in receiving messages sent from the Spider to the TaskTray…
I used Debug.Print to check the socket local and remote EndPoints I was using for my Spider ‘Listener’ method.

If I try to ‘read’ the Socket ‘RemoteEndPoint’ I loose the ability to receive data from my TaskTray application.
I added a Try/Catch and I do not receive any Exception.

Anybody know why this would occur?

Partial code where I loose the ability to receive.
Note that creating a string also causes the issue.


        void SetupListener()
        {
            readSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
           
            listenPortEndPoint = new IPEndPoint(IPAddress.Any, listenPort);
            readSocket.Bind(listenPortEndPoint);

            //This does not cause problems
            if (useDebug) { Debug.Print("readSocket LocalEndPoint: " + readSocket.LocalEndPoint.ToString()); }

            try
            {
                //Using either of the following prevents receiving data!!

                //  string test = readSocket.RemoteEndPoint.ToString();
                //or using
                //  Debug.Print("readSocket RemoteEndPoint: " + readSocket.RemoteEndPoint.ToString());
            }
            catch (Exception onDebug) //No exception received
            {
                Debug.Print(onDebug.ToString());
            }

            listenerThread = new Thread(new ThreadStart(ListenIncomming));
            listenerThread.Start();
        }
        //


Any help on receiving UDP at the TaskTray appreciated!

Have a GREAT DAY!

andre.marschalek

Thanks for the reply…
I believe my ‘Listening’ code is correct but I still cannot get anything at
if (readSocket.Poll(-1, SelectMode.SelectRead)) in my TaskTray App…

Guess I’ll spin wheels a bit longer trying to get data through to the TaskTray… Going the other was worked the first time I tried.

As to my comment “If I try to ‘read’ the Socket ‘RemoteEndPoint’ I loose the ability to receive data from my TaskTray application.”

I can ‘read’ all readable items in the socket EXCEPT RemoteEndPoint. Even if I set a breakpoint and ‘look’ at the Watch it breaks the socket.
No errors received. I just no longer receive messages at the Spider sent by the TaskTray App.

there is no reason to print out the remote endpoint until you receive a packet. what would you expect to be there?

andre.marschalek and mike

I’m no expert on using sockets. Sorry for my foolish question.

I had no idea about:

“the socket.RemoteEndpoint does not work with connectionless protocols”

I have never seen that stated as clear!

I will research further.

I still fine it odd that just ‘looking’ at the socket endpoint breaks the socket…

Thanks!