CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2008
    Posts
    61

    Angry Unknown Error while Socket Programming

    hey, how're you !?
    buddies, I had a problem while creating a sample application which I recently downloaded from Micorosoft MSDN online library ...
    here's is the picture of application :
    Code:
    http://www.turboimagehost.com/p/1817487/Error.JPG.html
    and this is the source code :
    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Net;
    using System.Net.Sockets;
    namespace Socket_Baseed_Application
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                TcpListener server = null;
                try
                {
                    Int32 port = 3333;
                    IPAddress localAddr = IPAddress.Parse("127.0.0.1");
                    server = new TcpListener(localAddr, port);
                    server.Start();
                    Byte[] bytes = new Byte[256];
                    string data = null;
                    while (true)
                    {
                        Console.WriteLine("waiting for a connection");
                        TcpClient client = server.AcceptTcpClient();
                        Console.WriteLine("Connected !");
                        data = null;
                        NetworkStream stream = client.GetStream();
                        int i;
                        while ((i=stream.Read(bytes,0,bytes.Length))!=0)
                        {
                            data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
                            Console.WriteLine("Recieved : {0}",data);
                            data = data.ToUpper();
                            byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);
                            stream.Write(msg, 0, msg.Length);
                            Console.WriteLine("Sent : {0}",data);
                        }
                        client.Close();
                    }
    
                }
                catch (SocketException e)
                {
                    Console.WriteLine("Socket Exception : {0}", e);
                }
                finally
                {
                    server.Stop();
                }
                Console.WriteLine("\nHit enter to continue ...");
                Console.Read();
    
            }
        }
    }
    I will really appreciate to one who can help me ...
    unfortunately, every application that I create with this class has the same problem ...,

    beforehand appreciate ...
    thanks .

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Unknown Error while Socket Programming

    The error message says very clearly that

    "The requested service provider could not be loade4d or initialized"

    That error is occurring in the Socket class constructor.

  3. #3
    Join Date
    Jul 2008
    Posts
    61

    Re: Unknown Error while Socket Programming

    give me a right way please, how can I solve this problem !?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured