N
nialltimpson
Could any one spare to seconds to see how im geting a class cast exception
here, ive been beating my head aginst the screen for a good long time now
and geting no where.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.math.BigInteger;
public class serverThreadSetup extends Thread implements Runnable{
public static final Vector eCommAttached = new Vector();
public static final Vector clientAttached = new Vector();
public static Socket eCommServer;
private ObjectInputStream in;
private ObjectOutputStream out;
String message;
String eCommMsg;
setupServer serv;
Object input;
//----------------------------------------------------------------------\\
public serverThreadSetup(Socket client) throws IOException{
out = new ObjectOutputStream(client.getOutputStream());
in = new ObjectInputStream(client.getInputStream());
setClient(client);
start();
}
//----------------------------------------------------------------------\\
private Socket client;
public void setClient(Socket client){
this.client = client;
clientAttached.add(this);
}
//----------------------------------------------------------------------//
public Socket getClient(){return client;}
public void run()
{
try{
while (setupServer.isServerUp()){
try{
out.writeObject("connected");
message = (String)in.readObject();
eCommMsg = (String)input;
System.err.println(message);
updateBroadcast(eCommMsg);
}
catch (ClassNotFoundException cnfe) {
System.err.println("CNFE");
}
}
}
catch (IOException ioe) {}
finally{
//close();
}
}
//----------------------------------------------------------------------//
public static void updateBroadcast(Object eCommMsg){
for (int i=0;i<eCommAttached.size();i++){
// the next line is the error.
((serverThreadSetup)eCommAttached.get(i)).updates(eCommMsg);
}
}
//----------------------------------------------------------------------\\
public void updates(Object eCommMsg)
{
try {
System.err.println("here4");
out.writeObject(eCommMsg);
}
catch (IOException ioe) {}
}
//----------------------------------------------------------------------\\
public void close(){
try{if (in!=null)
in.close();}
catch (IOException ioe){}
try{if (out!=null)out.close();}
catch (IOException ioe){}
try{if (client!=null)client.close();}
catch (IOException ioe){}
}
//----------------------------------------------------------------------
}
Im readin in an object, i.e string
Thank you very much who ever decides to help
Niall
here, ive been beating my head aginst the screen for a good long time now
and geting no where.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.math.BigInteger;
public class serverThreadSetup extends Thread implements Runnable{
public static final Vector eCommAttached = new Vector();
public static final Vector clientAttached = new Vector();
public static Socket eCommServer;
private ObjectInputStream in;
private ObjectOutputStream out;
String message;
String eCommMsg;
setupServer serv;
Object input;
//----------------------------------------------------------------------\\
public serverThreadSetup(Socket client) throws IOException{
out = new ObjectOutputStream(client.getOutputStream());
in = new ObjectInputStream(client.getInputStream());
setClient(client);
start();
}
//----------------------------------------------------------------------\\
private Socket client;
public void setClient(Socket client){
this.client = client;
clientAttached.add(this);
}
//----------------------------------------------------------------------//
public Socket getClient(){return client;}
public void run()
{
try{
while (setupServer.isServerUp()){
try{
out.writeObject("connected");
message = (String)in.readObject();
eCommMsg = (String)input;
System.err.println(message);
updateBroadcast(eCommMsg);
}
catch (ClassNotFoundException cnfe) {
System.err.println("CNFE");
}
}
}
catch (IOException ioe) {}
finally{
//close();
}
}
//----------------------------------------------------------------------//
public static void updateBroadcast(Object eCommMsg){
for (int i=0;i<eCommAttached.size();i++){
// the next line is the error.
((serverThreadSetup)eCommAttached.get(i)).updates(eCommMsg);
}
}
//----------------------------------------------------------------------\\
public void updates(Object eCommMsg)
{
try {
System.err.println("here4");
out.writeObject(eCommMsg);
}
catch (IOException ioe) {}
}
//----------------------------------------------------------------------\\
public void close(){
try{if (in!=null)
in.close();}
catch (IOException ioe){}
try{if (out!=null)out.close();}
catch (IOException ioe){}
try{if (client!=null)client.close();}
catch (IOException ioe){}
}
//----------------------------------------------------------------------
}
Im readin in an object, i.e string
Thank you very much who ever decides to help
Niall