Click here to Skip to main content
15,914,409 members
Home / Discussions / C#
   

C#

 
GeneralRe: WebBrowser/Threading issue Pin
DMBFiredancer15-Oct-06 11:15
DMBFiredancer15-Oct-06 11:15 
GeneralRe: WebBrowser/Threading issue Pin
Judah Gabriel Himango15-Oct-06 11:17
sponsorJudah Gabriel Himango15-Oct-06 11:17 
GeneralRe: WebBrowser/Threading issue Pin
DMBFiredancer15-Oct-06 11:51
DMBFiredancer15-Oct-06 11:51 
GeneralRe: WebBrowser/Threading issue Pin
Judah Gabriel Himango15-Oct-06 12:24
sponsorJudah Gabriel Himango15-Oct-06 12:24 
GeneralRe: WebBrowser/Threading issue Pin
DMBFiredancer15-Oct-06 12:30
DMBFiredancer15-Oct-06 12:30 
GeneralRe: WebBrowser/Threading issue Pin
DMBFiredancer16-Oct-06 2:44
DMBFiredancer16-Oct-06 2:44 
GeneralRe: WebBrowser/Threading issue Pin
Judah Gabriel Himango16-Oct-06 3:39
sponsorJudah Gabriel Himango16-Oct-06 3:39 
QuestionClient server application Pin
Airtel_nokia15-Oct-06 8:09
Airtel_nokia15-Oct-06 8:09 
I have a sample code for client server application : But could not able to send the request. Can anybody help me out to correct it?

This is the server code:
class MoneyServer
{
ArrayList talk = new ArrayList();
public MoneyServer()
{
talk.Add("A penny saved is too small, make it a buck");
talk.Add("Keep your wooden nickel. It will be worth something someday");
talk.Add("It's your dime, but u r a better if dialing 10-10-XXX.");
}


[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
MoneyServer mSvr =new MoneyServer();
ASCIIEncoding ASCII = new ASCIIEncoding();
Byte[] inStream = new Byte[256];
Byte[] outStream = new byte[256];
Random rnd;
string reqString="";
int index;
string choice = "Q";

TcpListener tcpl = new TcpListener(2010);
tcpl.Start();
Console.WriteLine("Server is running...");
choice = Console.ReadLine();
Console.WriteLine();
do
{
try
{
choice = Console.ReadLine();
Console.WriteLine();
Socket sock = tcpl.AcceptSocket();
int count = sock.Receive(inStream,inStream.Length,0);
reqString = ASCII.GetString(inStream,0,inStream.Length);
Console.WriteLine("reqString = " + reqString);

rnd = new Random();
index = rnd.Next(mSvr.talk.Count);
//outStream = ASCII.GetBytes((string)mSvr.talk[index]);
outStream = ASCII.GetBytes(choice);

sock.Send(outStream, outStream.Length, 0);
}
catch(Exception ex)
{
Console.WriteLine("Generic exception message : {0}",ex.Message);
}
}while(reqString != "bye");
tcpl.Stop();


}
}

This is the client code:
class EnterpreneurialClient
{
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
ASCIIEncoding ASCII = new ASCIIEncoding();
Byte[] inStream = new Byte[256];
Byte[] outStream = new Byte[256];
string freeAdvice;
string choice = "Q";

do
{
try
{
Console.WriteLine("\nMoney Line\n");
Console.WriteLine("1 - Get Advice");
Console.WriteLine("Q - Quite");
Console.WriteLine("\nPlease Choose: ");
choice = Console.ReadLine();
Console.WriteLine();

TcpClient myClient = new TcpClient("localhost", 2010);
Stream myStream = myClient.GetStream();
outStream = ASCII.GetBytes("What is the secreat of making money?");

if(choice == "1")
{
//send request to server
myStream.Write(outStream,0,outStream.Length);
//clean garbage chars from byte array
for(int i=0; i
QuestionWhy use CulturalInfo Pin
Mark0615-Oct-06 8:00
Mark0615-Oct-06 8:00 
AnswerRe: Why use CulturalInfo Pin
Guffa15-Oct-06 12:36
Guffa15-Oct-06 12:36 
AnswerRe: Why use CulturalInfo Pin
Monkeyget216-Oct-06 1:50
Monkeyget216-Oct-06 1:50 
GeneralRe: Why use CulturalInfo Pin
Mark0617-Oct-06 0:49
Mark0617-Oct-06 0:49 
GeneralRe: Why use CulturalInfo Pin
Monkeyget220-Oct-06 8:13
Monkeyget220-Oct-06 8:13 
Questionexit event handler Pin
m.m._200715-Oct-06 6:53
m.m._200715-Oct-06 6:53 
AnswerRe: exit event handler Pin
CWIZO15-Oct-06 7:58
CWIZO15-Oct-06 7:58 
AnswerRe: exit event handler Pin
sam#15-Oct-06 8:26
sam#15-Oct-06 8:26 
QuestionContent Base Retrivel of Audio & Vedio Data Pin
Muhammad Chitrali15-Oct-06 6:08
Muhammad Chitrali15-Oct-06 6:08 
AnswerRe: Content Base Retrivel of Audio & Vedio Data Pin
Amar Chaudhary15-Oct-06 15:00
Amar Chaudhary15-Oct-06 15:00 
Questionhow to put text in 50 labels Pin
Yustme15-Oct-06 2:33
Yustme15-Oct-06 2:33 
AnswerRe: how to put text in 50 labels Pin
Anthony Mushrow15-Oct-06 2:57
professionalAnthony Mushrow15-Oct-06 2:57 
GeneralRe: how to put text in 50 labels Pin
Yustme15-Oct-06 3:08
Yustme15-Oct-06 3:08 
GeneralRe: how to put text in 50 labels [modified] Pin
Anthony Mushrow15-Oct-06 3:17
professionalAnthony Mushrow15-Oct-06 3:17 
GeneralRe: how to put text in 50 labels Pin
Yustme15-Oct-06 3:31
Yustme15-Oct-06 3:31 
GeneralRe: how to put text in 50 labels Pin
Anthony Mushrow15-Oct-06 3:48
professionalAnthony Mushrow15-Oct-06 3:48 
GeneralRe: how to put text in 50 labels Pin
Yustme15-Oct-06 4:11
Yustme15-Oct-06 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.