_Manuel_
05-11-2009, 04:51
Salve!
Ho questo mini-client:
public class Client {
private PrintWriter out;
public Client() {
String dottedDecimalAddress = "96.255.1.16";
int port = 3456;
try {
socket = new Socket(dottedDecimalAddress , port);
out = new PrintWriter(socket.getOutputStream(), true);
} catch (IOException e) {
System.exit(-1);
}
}
public boolean send(String message)
{
out.write(message);
return true;
}
}
La creazione del socket avviene senza eccezioni.
L'invocazione della send avviene ed il messaggio inviato ha senso.
Poi ho questo miniserver:
public class Server {
public Server() {
int port = 3456;
try {
serverSocket = new ServerSocket(port);
} catch (IOException e) {
System.exit(-1);
}
Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
} catch (IOException e) {
System.exit(1);
}
try {
in = new BufferedReader(
new InputStreamReader(
clientSocket.getInputStream()));
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
t = new ReceiverThread(this);
t.start();
}
public void receive() {
try {
while ((inputLine = in.readLine()) != null) {
// operazioni sull'input
}
} catch (NumberFormatException e) {
e.printStackTrace();
return;
} catch (IOException e) {
e.printStackTrace();
return;
}
}
public class ReceiverThread extends Thread {
private RollerServer rs;
public ReceiverThread(RollerServer rs) {
this.rs = rs;
}
public void run() {
rs.receive();
}
}
Il flusso di esecuzione arriva fino alla ricezione (mi blocco sulla readLine() ) senza problemi, ma anche dopo che la send č stata invocata, sul server non ricevo nulla.
Quale puņ essere la causa?
Grazie
Ho questo mini-client:
public class Client {
private PrintWriter out;
public Client() {
String dottedDecimalAddress = "96.255.1.16";
int port = 3456;
try {
socket = new Socket(dottedDecimalAddress , port);
out = new PrintWriter(socket.getOutputStream(), true);
} catch (IOException e) {
System.exit(-1);
}
}
public boolean send(String message)
{
out.write(message);
return true;
}
}
La creazione del socket avviene senza eccezioni.
L'invocazione della send avviene ed il messaggio inviato ha senso.
Poi ho questo miniserver:
public class Server {
public Server() {
int port = 3456;
try {
serverSocket = new ServerSocket(port);
} catch (IOException e) {
System.exit(-1);
}
Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
} catch (IOException e) {
System.exit(1);
}
try {
in = new BufferedReader(
new InputStreamReader(
clientSocket.getInputStream()));
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
t = new ReceiverThread(this);
t.start();
}
public void receive() {
try {
while ((inputLine = in.readLine()) != null) {
// operazioni sull'input
}
} catch (NumberFormatException e) {
e.printStackTrace();
return;
} catch (IOException e) {
e.printStackTrace();
return;
}
}
public class ReceiverThread extends Thread {
private RollerServer rs;
public ReceiverThread(RollerServer rs) {
this.rs = rs;
}
public void run() {
rs.receive();
}
}
Il flusso di esecuzione arriva fino alla ricezione (mi blocco sulla readLine() ) senza problemi, ma anche dopo che la send č stata invocata, sul server non ricevo nulla.
Quale puņ essere la causa?
Grazie