Sockets -.-
Author |
Message |
Donny
|
Posted: Sun Apr 17, 2011 5:35 pm Post subject: Sockets -.- |
|
|
trying to make an online game, but i'm having troubles.
I'm not very good at java i've been teaching myself for a few weeks now but this has got me stumped.
CODE: |
public void communicate(int x2, int y2, int clientid) throws Exception{
Socket clientSocket = new Socket("localhost", 6789);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
DataInputStream inFromServer = new DataInputStream(clientSocket.getInputStream());
clientid = inFromServer.readInt();
System.out.println(clientid);
outToServer.writeInt(x2);
outToServer.writeInt(y2);
x3 = inFromServer.readInt();
y3 = inFromServer.readInt();
System.out.println(x3);
System.out.println(y3);
} |
I need to be able to access the x3 and y3 outside of the communicate void but it always returns the value as 0, when i put println with x3 outside it just prints 0, how can I make it do anything? i've tried making public int setX(){return this.x3} and such but it still won't work, any suggestions? (it does print the proper x and y values in the console just not when i try outside of the class) |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
|
|
|
 |
Donny
|
Posted: Sun Apr 17, 2011 7:47 pm Post subject: RE:Sockets -.- |
|
|
It's in the variables part
CODE: |
Class example extends Applet {
public int x3, y3;
public void init(){
}
} |
|
|
|
|
|
 |
|
|