F
fAnSKyer/C# newbie
private void startupServer() {
try {
serverscoket = new ServerSocket(Listener.PORTNUMBER);
SERVER_ON = true;
} catch (IOException e1) {
e1.printStackTrace();
}
}
public void run() {
while (SERVER_ON) {
establishConnection();
while (CONNECTION) {
try {
message = null;
message = inputBuffer.readLine();
}
------------------------------------------------
My approach is
try
{
TcpClient tcpClient =new TcpClient ("localhost",
9001);//connect to the server
NetworkStream netStream = tcpClient.GetStream();//
read the stream
StreamReader sr = new StreamReader(netStream);//
streamreader
while (tcpClient.Connected)
{
String temp = sr.ReadLine();
Log.Text += temp + ".\r\n";
However, mine doesn't work and it stuck at
String temp = sr.ReadLine();
Can anybody give me an idea? or another way to do the same thing as
the java code do?
Thanks a lot
try {
serverscoket = new ServerSocket(Listener.PORTNUMBER);
SERVER_ON = true;
} catch (IOException e1) {
e1.printStackTrace();
}
}
public void run() {
while (SERVER_ON) {
establishConnection();
while (CONNECTION) {
try {
message = null;
message = inputBuffer.readLine();
}
------------------------------------------------
My approach is
try
{
TcpClient tcpClient =new TcpClient ("localhost",
9001);//connect to the server
NetworkStream netStream = tcpClient.GetStream();//
read the stream
StreamReader sr = new StreamReader(netStream);//
streamreader
while (tcpClient.Connected)
{
String temp = sr.ReadLine();
Log.Text += temp + ".\r\n";
However, mine doesn't work and it stuck at
String temp = sr.ReadLine();
Can anybody give me an idea? or another way to do the same thing as
the java code do?
Thanks a lot