Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: Controls Leave Event - Help Pin
Wjousts18-Oct-05 3:33
Wjousts18-Oct-05 3:33 
GeneralRe: Controls Leave Event - Help Pin
Craig G Fraser18-Oct-05 3:39
Craig G Fraser18-Oct-05 3:39 
GeneralRe: Controls Leave Event - Help Pin
Wjousts18-Oct-05 3:46
Wjousts18-Oct-05 3:46 
Questionencryption in c# Pin
sandy_francs18-Oct-05 1:13
sandy_francs18-Oct-05 1:13 
AnswerRe: encryption in c# Pin
Vikram A Punathambekar18-Oct-05 1:37
Vikram A Punathambekar18-Oct-05 1:37 
GeneralRe: encryption in c# Pin
sandy_francs18-Oct-05 16:14
sandy_francs18-Oct-05 16:14 
AnswerRe: encryption in c# Pin
Ryan Roberts18-Oct-05 1:41
Ryan Roberts18-Oct-05 1:41 
Questionhi all Pin
magnifique18-Oct-05 0:37
magnifique18-Oct-05 0:37 
i am try to write tcp client an server but any time it get to the streamReader it hungs.

can someone help me with these code

Client Code

public string RunClient(string address,int port)
{
string response="";
//set up a listener on that address/port
TcpClient tcpClient=new TcpClient(address,port);
if(tcpClient!=null)
{
string message="Hello There";
//translate the message into UTFASCII and store it as a byte array
byte[] bytes=Encoding.ASCII.GetBytes(message);

NetworkStream stream=tcpClient.GetStream();

//send message to the connected tcpServer
//the write flushes the stream automatically here
stream.Write(bytes,0,bytes.Length);

//get the response from the server

StreamReader reader=new StreamReader(stream,Encoding.UTF8);
try
{
response=reader.ReadToEnd();
}
finally
{
//close reader
reader.Close();
}
//close client
tcpClient.Close();
}
//return response to text
return response;
}


Server Code

public static void RunServer(string address,int port)
{
//set up address
IPAddress addr=IPAddress.Parse(address);
//set up listener on that address/port
TcpListener tcpListener=new TcpListener(addr,port);
if(tcpListener !=null)
{
//start it up
tcpListener.Start();
//wait for tcp client to connect
TcpClient tcpClient=tcpListener.AcceptTcpClient();

byte[]bytes=new byte[1024];
//get the client stream

NetworkStream ClientStream=tcpClient.GetStream();
Stream str=ClientStream;
StreamReader reader=new StreamReader(ClientStream,Encoding.UTF8);
try
{
string request=reader.ReadToEnd();

//just send an acknowlegment
bytes=Encoding.UTF8.GetBytes("Thanks for the message");
ClientStream.Write(bytes,0,bytes.Length);
}
finally
{
//close the resder
reader.Close();
}
//stop listeneing
tcpListener.Stop();
}
}
AnswerRe: hi all Pin
Rob Philpott18-Oct-05 1:10
Rob Philpott18-Oct-05 1:10 
QuestionMerging cells Pin
servik18-Oct-05 0:32
servik18-Oct-05 0:32 
QuestionNUMERIC DataGridViewColumn Pin
Greeky18-Oct-05 0:01
Greeky18-Oct-05 0:01 
AnswerRe: NUMERIC DataGridViewColumn Pin
Robert Rohde18-Oct-05 6:00
Robert Rohde18-Oct-05 6:00 
Questioniterating ResourceManager Pin
chettu17-Oct-05 23:51
chettu17-Oct-05 23:51 
QuestionAdd a toolbar in the windows deskbar... Pin
seup17-Oct-05 23:38
seup17-Oct-05 23:38 
AnswerRe: Add a toolbar in the windows deskbar... Pin
seup19-Oct-05 6:39
seup19-Oct-05 6:39 
QuestionODBC Dataadapter - Error HY007 on update! Pin
Patrick Klug17-Oct-05 22:33
Patrick Klug17-Oct-05 22:33 
AnswerRe: ODBC Dataadapter - Error HY007 on update! Pin
Gavin Jeffrey18-Oct-05 3:56
Gavin Jeffrey18-Oct-05 3:56 
GeneralRe: ODBC Dataadapter - Error HY007 on update! Pin
Patrick Klug18-Oct-05 6:00
Patrick Klug18-Oct-05 6:00 
QuestionWindows crash (BSOD) when compiling in VS.NET Pin
dorwin17-Oct-05 22:23
dorwin17-Oct-05 22:23 
AnswerRe: Windows crash (BSOD) when compiling in VS.NET Pin
leppie18-Oct-05 5:15
leppie18-Oct-05 5:15 
QuestionRegarding the ZedGraph Chart control that was posted by our friend JChampion Pin
sukanyavarma17-Oct-05 21:28
sukanyavarma17-Oct-05 21:28 
Questiontooltip on listbox Pin
Mridang Agarwalla17-Oct-05 21:12
Mridang Agarwalla17-Oct-05 21:12 
AnswerRe: tooltip on listbox Pin
Wjousts18-Oct-05 3:44
Wjousts18-Oct-05 3:44 
Questioncall a form and return the result Pin
Mridang Agarwalla17-Oct-05 21:05
Mridang Agarwalla17-Oct-05 21:05 
AnswerRe: call a form and return the result Pin
S. Senthil Kumar18-Oct-05 0:33
S. Senthil Kumar18-Oct-05 0:33 

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.