karthik ts

Greenhorn
+ Follow
since Feb 16, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by karthik ts

Hello,
if U have that much of patience tell me why sending to Client is not achieved while receiving is possible from client.
Ofcoarse that too works only if I commented the sendall class and its thread. The sendall thread broadcasts to everyclients that is being stored in the Vector.
Help me if U could!!! plz............
Below is the Server side program:
import java.net.*;
import java.io.*;
import java.util.*;
public class Forsc1
{
static Vector listof=new Vector();
public static void main(String args[])
{
Socket Client;
try
{
ServerSocket ss=new ServerSocket(5555);
while(true)
{
Client=ss.accept();
Receive r=new Receive(Client);
System.out.println("connected: "+Client.getInetAddress().getHostName());
r.start();
listof.add(Client);
Sendall toall=new Sendall();
toall.start();
}
}
catch (Exception e)
{}
}
}
class Receive extends Thread
{
Socket client;
Vector v=new Vector();
Vector history=new Vector();
ObjectInputStream in;
Object o;
public Receive(Socket c)
{
client=c;
try
{
in=new ObjectInputStream(client.getInputStream());
}
catch(Exception e)
{}
}
public void run()
{
int h,q=0;
try
{
synchronized(o)
{
q++;
o=in.readObject();
v=(Vector) o;
for(h=0;h<v.size();h++)>
{
System.out.println("received :"+v.elementAt(h));
}
sleep(100);
}
}
catch(Exception e)
{}
}
}
class Sendall extends Thread
{
Vector all;
Socket s;
Object came;
ObjectOutputStream op;
Forsc con=new Forsc();
Receive rec;
public Sendall()
{
all=con.listof;
came=rec.o;
System.out.println("no.of clients ====="+all.size());
}
public void run()
{
for(int k=0;k<all.size();k++)>
{
try
{
s=(Socket) all.elementAt(k);
op=new ObjectOutputStream(s.getOutputStream());
System.out.println("sending to "+s);
op.writeObject(came);
}
catch(Exception e)
{}
}
}
}

______________________________________________________________
Below is the Clientside program
import java.io.*;
import java.net.*;
import java.util.*;
public class Forc
{
static Socket socks;
public static void main(String args[])
{
try
{
socks=new Socket("localhost",5555);
}
catch(Exception e)
{}
Send s=new Send(socks);
s.start();
Receive r=new Receive(socks);
r.start();
}
}
class Send extends Thread
{
Socket socks;
ObjectOutputStream o;
Vector v=new Vector();
public Send(Socket s)
{
socks=s;
try
{
o=new ObjectOutputStream(socks.getOutputStream());
}
catch(IOException e)
{}
for(int i=1;i<=100;i++)
{
v.addElement(new Integer(i));
}
}
public void run()
{
try
{
synchronized(o)
{
o.writeObject(v);
try
{
this.sleep(1000);
}
catch(Exception e)
{}
System.out.println("sended "+v.elementAt(y));
}
}
catch(IOException e)
{}
}
}
class Receive extends Thread
{
ObjectInputStream ois;
Vector g=new Vector();
Socket socks;
Object oops;
public Receive(Socket s)
{
socks=s;
try
{
ois=new ObjectInputStream(socks.getInputStream());
}
catch(IOException e)
{}
}
public void run()
{
try
{
oops=ois.readObject();
if(oops instanceof Vector)
{
g=(Vector) oops;
}
for(int i=0;i<g.size();i++)>
{
System.out.println("received "+g.elementAt(i));
}
}
catch(Exception e)
{}
}
}

Thanking U



23 years ago
Hello,
if U have that much of patience tell me why sending to Client is not achieved while receiving is possible from client.
Ofcoarse that too works only if I commented the sendall class and its thread. The sendall thread broadcasts to everyclients that is being stored in the Vector.
Help me if U could!!! plz............
Below is the Server side program:
import java.net.*;
import java.io.*;
import java.util.*;
public class Forsc1
{
static Vector listof=new Vector();
public static void main(String args[])
{
Socket Client;
try
{
ServerSocket ss=new ServerSocket(5555);
while(true)
{
Client=ss.accept();
Receive r=new Receive(Client);
System.out.println("connected: "+Client.getInetAddress().getHostName());
r.start();
listof.add(Client);
Sendall toall=new Sendall();
toall.start();
}
}
catch (Exception e)
{}
}
}
class Receive extends Thread
{
Socket client;
Vector v=new Vector();
Vector history=new Vector();
ObjectInputStream in;
Object o;
public Receive(Socket c)
{
client=c;
try
{
in=new ObjectInputStream(client.getInputStream());
}
catch(Exception e)
{}
}
public void run()
{
int h,q=0;
try
{
synchronized(o)
{
q++;
o=in.readObject();
v=(Vector) o;
for(h=0;h<v.size();h++)
{
System.out.println("received :"+v.elementAt(h));
}
sleep(100);
}
}
catch(Exception e)
{}
}
}
class Sendall extends Thread
{
Vector all;
Socket s;
Object came;
ObjectOutputStream op;
Forsc con=new Forsc();
Receive rec;
public Sendall()
{
all=con.listof;
came=rec.o;
System.out.println("no.of clients ====="+all.size());
}
public void run()
{
for(int k=0;k<all.size();k++)
{
try
{
s=(Socket) all.elementAt(k);
op=new ObjectOutputStream(s.getOutputStream());
System.out.println("sending to "+s);
op.writeObject(came);
}
catch(Exception e)
{}
}
}
}

______________________________________________________________
Below is the Clientside program
import java.io.*;
import java.net.*;
import java.util.*;
public class Forc
{
static Socket socks;
public static void main(String args[])
{
try
{
socks=new Socket("localhost",5555);
}
catch(Exception e)
{}
Send s=new Send(socks);
s.start();
Receive r=new Receive(socks);
r.start();
}
}
class Send extends Thread
{
Socket socks;
ObjectOutputStream o;
Vector v=new Vector();
public Send(Socket s)
{
socks=s;
try
{
o=new ObjectOutputStream(socks.getOutputStream());
}
catch(IOException e)
{}
for(int i=1;i<=100;i++)
{
v.addElement(new Integer(i));
}
}
public void run()
{
try
{
synchronized(o)
{
o.writeObject(v);
try
{
this.sleep(1000);
}
catch(Exception e)
{}
System.out.println("sended "+v.elementAt(y));
}
}
catch(IOException e)
{}
}
}
class Receive extends Thread
{
ObjectInputStream ois;
Vector g=new Vector();
Socket socks;
Object oops;
public Receive(Socket s)
{
socks=s;
try
{
ois=new ObjectInputStream(socks.getInputStream());
}
catch(IOException e)
{}
}
public void run()
{
try
{
oops=ois.readObject();
if(oops instanceof Vector)
{
g=(Vector) oops;
}
for(int i=0;i<g.size();i++)
{
System.out.println("received "+g.elementAt(i));
}
}
catch(Exception e)
{}
}
}

Thanking U



23 years ago
Hello,
if U have that much of patience tell me why sending to Client is not achieved while receiving is possible from client.
Ofcoarse that too works only if I commented the sendall class and its thread. The sendall thread broadcasts to everyclients that is being stored in the Vector.
Help me if U could!!! plz............
Below is the Server side program:

______________________________________________________________
Below is the Clientside program

Thanking U


I editted this and added the UBB tag for code, How to use UBB tags is descriped Here
[This message has been edited by Carl Trusiak (edited February 25, 2001).]
[This message has been edited by Carl Trusiak (edited February 25, 2001).]
Hello,
if U have that much of patience tell me why sending to Client is not achieved while receiving is possible from client.
Ofcoarse that too works only if I commented the sendall class and its thread. The sendall thread broadcasts to everyclients that is being stored in the Vector.
Help me if U could!!! plz............
Below is the Server side program:
import java.net.*;
import java.io.*;
import java.util.*;
public class Forsc1
{
static Vector listof=new Vector();
public static void main(String args[])
{
Socket Client;
try
{
ServerSocket ss=new ServerSocket(5555);
while(true)
{
Client=ss.accept();
Receive r=new Receive(Client);
System.out.println("connected: "+Client.getInetAddress().getHostName());
r.start();
listof.add(Client);
Sendall toall=new Sendall();
toall.start();
}
}
catch (Exception e)
{}
}
}
class Receive extends Thread
{
Socket client;
Vector v=new Vector();
Vector history=new Vector();
ObjectInputStream in;
Object o;
public Receive(Socket c)
{
client=c;
try
{
in=new ObjectInputStream(client.getInputStream());
}
catch(Exception e)
{}
}
public void run()
{
int h,q=0;
try
{
synchronized(o)
{
q++;
o=in.readObject();
v=(Vector) o;
for(h=0;h<v.size();h++)>
{
System.out.println("received :"+v.elementAt(h));
}
sleep(100);
}
}
catch(Exception e)
{}
}
}
class Sendall extends Thread
{
Vector all;
Socket s;
Object came;
ObjectOutputStream op;
Forsc con=new Forsc();
Receive rec;
public Sendall()
{
all=con.listof;
came=rec.o;
System.out.println("no.of clients ====="+all.size());
}
public void run()
{
for(int k=0;k<all.size();k++)>
{
try
{
s=(Socket) all.elementAt(k);
op=new ObjectOutputStream(s.getOutputStream());
System.out.println("sending to "+s);
op.writeObject(came);
}
catch(Exception e)
{}
}
}
}

______________________________________________________________
Below is the Clientside program
import java.io.*;
import java.net.*;
import java.util.*;
public class Forc
{
static Socket socks;
public static void main(String args[])
{
try
{
socks=new Socket("localhost",5555);
}
catch(Exception e)
{}
Send s=new Send(socks);
s.start();
Receive r=new Receive(socks);
r.start();
}
}
class Send extends Thread
{
Socket socks;
ObjectOutputStream o;
Vector v=new Vector();
public Send(Socket s)
{
socks=s;
try
{
o=new ObjectOutputStream(socks.getOutputStream());
}
catch(IOException e)
{}
for(int i=1;i<=100;i++)
{
v.addElement(new Integer(i));
}
}
public void run()
{
try
{
synchronized(o)
{
o.writeObject(v);
try
{
this.sleep(1000);
}
catch(Exception e)
{}
System.out.println("sended "+v.elementAt(y));
}
}
catch(IOException e)
{}
}
}
class Receive extends Thread
{
ObjectInputStream ois;
Vector g=new Vector();
Socket socks;
Object oops;
public Receive(Socket s)
{
socks=s;
try
{
ois=new ObjectInputStream(socks.getInputStream());
}
catch(IOException e)
{}
}
public void run()
{
try
{
oops=ois.readObject();
if(oops instanceof Vector)
{
g=(Vector) oops;
}
for(int i=0;i<g.size();i++)>
{
System.out.println("received "+g.elementAt(i));
}
}
catch(Exception e)
{}
}
}

Thanking U



Hello,
here's a problem, really annoying!!
somebody tell me why is'nt the server not able to print the Objects of the Client.
The Client sets the vector object into the stream and the server is ready to capture the object. But unable to find where the hole is in printing the objects captured by the server. Have a look at this below.


(edited by Cindy to format code)

[This message has been edited by Cindy Glass (edited February 17, 2001).]
23 years ago
Hello,
I have no idea in sending and receiving the Vector's object into the stream and catching it back or in distributing the same to different sockets.
what r all the possibilities in doing it?
thanx;
hello,
I have no idea about passing Vector's object thru the proper stream.
I have stored some values in the Vector which would get erased during the mouseRelease Event. Never bother about it!
But tell me how to transfer the object of the vector inside
Thanx
___karthik
23 years ago