#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Malaysia
    Posts
    42
    Rep Power
    12

    using RDM socket in C#


    hi guys, please guide me on using RDM socket in C#.

    what is the requirement to use SocketType.Rdm ??? how do I declare the socket and what SocketOption should I declare ?

    -------------

    I declared it with :
    Code:
     server = new Socket( AddressFamily.InterNetwork, SocketType.Rdm, ProtocolType.Tcp );
    It gave me an error:

    System.Net.Sockets.SocketException: The requested protocol has not been configured into the system, or no implementation for it exists
    at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)

    --------------------

    I dont have any idea how to configure this socket. I have searched MSDN library, but still not much information are provided.

    I need it because I need to build a multicast application with reliable multicast protocol like PGM ( pragmatic general multicasting ). If you all have other suggestions, please kindly let me know. I am really desperated to finish this project.

    Thank you so much.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Malaysia
    Posts
    42
    Rep Power
    12
    Finally I made it. I only managed to connect client and server using PGM protocol. And failed to use RM_SENDER_STATISTICS and RM_RECEIVER_STATISTICS.

    Server side

    Code:
    private Socket server;
    
    private IPAddress ipMC;
    private IPAddress ipLocal;
    private IPEndPoint iep1;				
    private IPEndPoint iep2;
    private EndPoint ep;
    	
    // create server socket
    server = new Socket( AddressFamily.InterNetwork, 
    	SocketType.Rdm, 
    	(ProtocolType)113 );
    
    ipLocal = IPAddress.Any;
    iep1 = new IPEndPoint(ipLocal, 0);				
    
    // bind socket to network interface IP address ANY 
    server.Bind(iep1);
    
    ipMC = IPAddress.Parse( "230.100.100.100" );				
    lblAddress.Text = ipMC.ToString();				
    iep2 = new IPEndPoint(ipMC, 9999);
    
    ep = (EndPoint) iep2;
    
    // connect socket to multicast address group
    server.Connect( ep );  
    
    
    //
    // send data
    //
    byte[] data = Encoding.ASCII.GetBytes( txtMsg.Text );				
    server.Send( data );

    Client Side

    Code:
    private Socket client;
    private Socket clientRead;
    
    private IPAddress ipMC;
    private IPEndPoint iepMC;
    private EndPoint ep;
    
    private Thread receiverThread;
    	
    // create the socket
    client = new Socket( AddressFamily.InterNetwork, 
    	SocketType.Rdm, 
    	(ProtocolType)113 );
    
    ipMC = IPAddress.Parse( "230.100.100.100" );
    iepMC = new IPEndPoint( ipMC, 9999 );
    ep = (EndPoint)iepMC;			
    
    // bind socket to multicast group
    client.Bind(ep);
    client.Listen(10);			
    
    // start multithreading to be able to receive packets
    receiverThread = new Thread(new ThreadStart(packetReceive));
    receiverThread.IsBackground = true;
    receiverThread.Start();
    
    lstLog.Items.Add( "Ready to receive messages !" );
    cmdListen.Enabled = false;
    
    // receive function
    
    private void packetReceive()
    	{
    		try
    		{
    			// enable socket for accepting connections
    			clientRead = client.Accept();
    
    			byte[] data = new byte[1024];
    			string stringData;
    			int recv;
    			while (true)
    			{				
    				recv = clientRead.Receive( data ); 					
    				stringData = Encoding.ASCII.GetString(data, 0, recv);
    			}
    		}
    		catch( Exception eb )
    		{
    		}
    	}

IMN logo majestic logo threadwatch logo seochat tools logo