Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 tcp/ip

Author  Topic 

q8z
Starting Member

3 Posts

Posted - 2005-06-30 : 09:28:51
the cod of the client is good
i want that the server will return to the client the text that the client send
when i run this program it work
but i want to send to the client the text that the client send and not "ok"
so when i try to do this - i get error
what shold i fix in my cod?
this is the cod of thw server
using System;
using System.Net;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.IO.IsolatedStorage;
using System.Threading;
using System.Net.Sockets;
using System.Text;
using System.Globalization;

namespace WinServer
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
bool[] l = new bool[20];
for (int i=0;i<20;i++){
l[i] = false;
}
int count=0;
TcpListener tcpl = new TcpListener(5555);
string str;
tcpl.Start();
Console.WriteLine("Waiting for clients to connect");
Console.WriteLine("Press Ctrl+c to Quit...");
while (true)
{
char[] c = new char[2];
c[0] = 'o'; c[1] = 'k';
Socket s = tcpl.AcceptSocket();
NetworkStream ns = new NetworkStream(s);
StreamReader sr = new StreamReader(ns);
//sr.Read(c, 0, c.Length);
Byte[] byteDateLine = Encoding.ASCII.GetBytes(c);
s.Send(byteDateLine, byteDateLine.Length, 0);
s.Close();
}
}
}
}
   

- Advertisement -