dcsimg
System hanged during sending huge sending very frequently.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, September 18, 2001 10:05 PM

The Requirement I want a TCP bridge to pass data from one user to another user separated by internet. For this I choose JAVA. VJ++ is used at the client side and on server I have written code in sun java. I write a client side program and compiles it to make a dll. This dll is being used in VB. My VB application is basically a chat kind of application but data has to send in a single click is very heavy(around 160 character long string) Now user is supposed to type on the keyboard and with every press of key this data has to pass over the net. Application works very fine when I test it with my LAN connection. This problem I am facing with Internet only. The structure of network is:    More>>

The Requirement

I want a TCP bridge to pass data from one user to another user separated by internet.
For this I choose JAVA. VJ++ is used at the client side and on server I have written code in sun java.
I write a client side program and compiles it to make a dll.
This dll is being used in VB.
My VB application is basically a chat kind of application but data has to send in a single click is very heavy(around 160 character long string)
Now user is supposed to type on the keyboard and with every press of key this data has to pass over the net.

Application works very fine when I test it with my LAN connection. This problem I am facing with Internet only.

The structure of network is:
Client-server-client

Both clients are supposed to exist on the server before starting of data exchange among them. Means handshaking is performed.
Once they are connected then the data starts traveling between two.

Client program:
Client is made a bean. It have some properties and methods explored to VB.
It has one thread to receive the data. When VB wants to send data it is calling Java DLL’s method with argument as data.
In java DLL I have opened a socket first. Then taking a DataInputStream out of it. WriteUTF(“data”) method is being used to send the data to network.

A typical code is like this

public void connect() //Open the connection with the appropriate server
{
try
{
Socket socket=new Socket(getInetAddress(),getPortNo());
dataout=new DataOutputStream(socket.getOutputStream());
datain=new DataInputStream(socket.getInputStream());
dataout.writeUTF("SHAKE_HAND ");
//here this is handshaking string
mainThread.start();

}
catch(Exception e){e.printStackTrace();}
}

Runnable mainRun=new Runnable()
{
public void run()
{
try{
while(mainLoop)
{
String fromServer=null;
if(datain!=null)
{
try{
fromServer=datain.readUTF();
//process it and pass it to VB
}
catch(SocketException se)
{
onErrorEvent(new Event());
break;
}catch(IOException ioe)
{
onErrorEvent(new Event());
break;
}
catch(Exception se){}
}
}catch(Exception e ){}
}
}

//this method is called with every 200milli seconds by VB(may change)
public void sendDataOnServer(String header, String data)
{
if(header!="" && data!="")
{
try{
dataout.writeUTF(header);
dataout.writeUTF(data);
}catch(Exception e){}
}
}

Now in time which I have written i.e 200milli seconds, we are finding that machine hangs very often some times even after typing 10 characters. If we increase this time than it goes to around 20 – 25 characters.

So please suggest me how to transmit such a heavy amount of data and at such a high speed.

I can think of stopping the input to socket if I get the confirmation that what ever I have written on the server has been released from client socket. But in java I could not find such a method.

So first of all tell me, Is there any such event, which gets fired when data has gone out of the machine buffer? As there is one in winSock “sendDataComplete”. So when I will get this event then only I will release my next data string.

Please help me out
I shall be very thankful to you.


Prakash Rao


mail me: prakraoin@yahoo.com

   <<Less
About | Sitemap | Contact