Sami_codes_AllDay's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Contributors
Active Posts:
40 (0.03 per day)
Joined:
09-August 11
Profile Views:
1,385
Last Active:
User is offline May 13 2015 04:31 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Nintendo
Your Car:
Who Cares
Dream Kudos:
50
Icon   Sami_codes_AllDay If you're not confused and scratching your head, then you're not tackling difficult enough problems...

Posts I've Made

  1. In Topic: An unhandled exception of type 'System.Windows.Markup.XamlParseExc

    Posted 13 May 2015

    Thank you for your helpful advice tlhIn. Not to worry, I was not leaving the socket open indefinitely. I have two event handlers, one which creates the socket once the window opens and one which tears down the socket once the window closes. Yes, it's not the recommended paradigm for socket usage, however, it's what is needed for my specific application. Within this same thread, I'm having a difficult time trying to pass the socket around and give full visibility to the socket among my existing classes.

    In other words, how do I allow 3 separate classes (all within the same namespace), to listen to and write to the same socket? I've done a lot of reading behind the subject (using a Singleton object seemed to be the most prevalent way around this, although being a new at C#, I couldn't quite get the Singleton right). Here is a pertinent snippet of the code:


    
    namespace Original_Remote_Monitor
    {
    
        // Assume socket was successfully opened.  
    
        public class myServer
        {
            // Establish the remote endpoint for the socket.
            // myServer uses port 27015 and IP address "10.10.128.48".
            public IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("10.10.128.48"), 27015);
            // Create a TCP/IP socket.
            public Socket theSender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     
            public void writeToMyServer(IPEndPoint EP, Socket Client)
            {
              // This method works fine as the socket is "visible" to the method.
            }
            
        } // End of myServer.
    
    
    
        public class myDevice_A
        {
    
            public void writeToDeviceA (IPEndPoint EP, Socket Client)
            {
              // This method cannot write to the socket, although the socket was previously opened!
            }
            
        } // End of myDevice_A.
    
    
    
        public class myDevice_B
        { 
           public void writeToDeviceB (IPEndPoint EP, Socket Client)
           {
               // This method cannot write to the socket, although the socket was previously opened!
           }
    
        } // End of myDevice_B.
    
    
    } // End of namespace
    
    
    
    



    Thank you,

    SB
  2. In Topic: An unhandled exception of type 'System.Windows.Markup.XamlParseExc

    Posted 8 May 2015

    Thank you tlhIn. I went ahead and did as you prescribed. The exception is being thrown in my "SpiWrite()" method within the class "SerialComm".

    "A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
    Additional information: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied."

    This exception is a bit confusing as I opened the Socket within the "MainWindow()" method (line 120) and perform a check to see that the socket is indeed opened. I can confirm that the socket is open (in theory) by viewing the traffic with my hyper-terminal link. I'll go ahead and check the downstream buffer to see if the array "buffer" is stepping out of bounds, although figured that .net would bark at me if I was stepping out of bounds in an array.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Years Programming:
13
Programming Languages:
C/C++, C#, Python, PERL, Matlab

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

Sami_codes_AllDay has no profile comments yet. Why not say hello?