Results 1 to 1 of 1
- 07-12-2011, 06:08 PM #1
Member
- Join Date
- May 2011
- Posts
- 10
- Rep Power
- 0
Really big problem in client and server program
Friends here is my client program in java using sockets
import java.io.*;
import java.net.*;
class Client
{
int count=0;
public static void main(String args[]) throws Exception
{
int count=0;
Socket s=new Socket("LocalHost",2000);
DataOutputStream dos=new DataOutputStream(s.getOutputStream());
String str=new String();
while(true)
{
try
{
Thread.sleep(1000);
count++;
str=""+count+"";
dos.writeBytes("str");
System.out.println(str);
}
catch(Exception e)
{}
}
}
}
Here client sends number(actually string) to server by using thread and incrementing a variable for every 1 second.
And server program is
import java.io.*;
import java.net.*;
class Server
{
public static void main(String args[]) throws Exception
{
ServerSocket ss=new ServerSocket(2000);
Socket s=ss.accept();
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=dis.readLine();
System.out.println("While");
while(true)
{
System.out.println(str);
str=dis.readLine();
}
}
}
Now the big problem is server is not getting data from server but client is posting the values the server program sucks in the line "String str=dis.readLine();"..
So please help me in getting this code..
Thanks.....









Similar Threads
-
Simple Client (2) - Server program
By Reztem in forum New To JavaReplies: 2Last Post: 01-09-2012, 02:05 AM -
Really big problem in client and server program
By helioshilary in forum New To JavaReplies: 14Last Post: 07-13-2011, 01:17 PM -
how to run server-client program in desktop application??
By miu44 in forum NetBeansReplies: 1Last Post: 02-16-2011, 10:05 AM -
Client Server program, a tiny problem.
By skarosg3 in forum NetworkingReplies: 12Last Post: 05-27-2010, 01:03 PM -
Multithreaded Client/Server Chat program
By f0ns in forum Threads and SynchronizationReplies: 3Last Post: 10-21-2009, 05:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks