Click to See Complete Forum and Search --> : Unknown Error while Socket Programming


escap3
June 12th, 2009, 04:39 PM
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 :
http://www.turboimagehost.com/p/1817487/Error.JPG.html
and this is the source 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 .

BigEd781
June 12th, 2009, 04:45 PM
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.

escap3
June 12th, 2009, 06:08 PM
give me a right way please, how can I solve this problem !?