![]() | |
| | #1 (permalink) |
| Üye Üyelik Tarihi: 10/2004
Mesaj: 8
|
Selam Bir server client uygulaması yazıyorum. Uygulamayı editör(eclipse, idea...) üzerinde çalıstırdığımda bir client appleti server ile ve onun üzerinden de başka bir applet ile haberleşmekte hiç sorun yaşamıyor. Appleti jar yapıp web de çalıştırdığımda ise server uygulamasının yolladığı mesajları okumuyor. Hiç bir hata da oluşmuyor. Kendi çaplarında bekleşiyorlar. Sorun ne olabilir? Reader, writer uyumsuzluğundan kaynaklanıyor acep? Sorunla ilgili olabileceğini sandığım kodların bazılarını yazıyorum. Teşekkürler. //Server tarafının haberleşme ile alakalı parça parça kodları Kod: ClientConnection implements Runnable {
private Socket sock;
private BufferedReader in;
//private OutputStream out;
private String host;
private Server server;
private Writer writer;
private static final String CRLF = "\r\n";
private String name = null ;
private String id;
private boolean busy = false;
public ClientConnection(Server srv, Socket s, int i) {
try {
server = srv;
sock = s;
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
//out = s.getOutputStream();
this.writer = new OutputStreamWriter(s.getOutputStream(), "UTF-8");
host = s.getInetAddress().getHostName();
id = "" + i;
write(
"id " + id + CRLF );
new Thread(this).start();
}
catch (IOException e) {
System.
out.println("failed ClientConnection " + e);
}
}
public
void write(String s) {
char buf[];
buf = s.toCharArray();
try {
this.writer.write(buf, 0, buf.length );
writer.flush();
}
catch (IOException e) {
close();
}
}
public
void write(char cbuf[], int off, int len) throws IOException {
try{
for (int i = 0; i < len; i++) {
char c = cbuf[off + i];
if (c != '\r')
buf.append(c);
if (c == '\n') {
synchronized (out) {
out.write(buf.toString());
System.
out.println("send "+ buf.toString());
}
buf.setLength(0);
buf.append(channel);
}
}
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//********************************************************
//Applet client kodları
this
.reader = new BufferedReader( new InputStreamReader(this.socket
.getInputStream(), "UTF-8"), 1);
---------------------------
public ChannelReader(int channel, TavServerConnection conn) {
this.channel = channel;
this.connection = conn;
connection.addChannelListener(this);
}
public ChannelReader(int channel) {
this.channel = channel;
}
private StringBuffer buf = new StringBuffer();
----------------
public synchronized int read(char[] cbuf, int off, int len)
throws IOException {
if (buf == null ) {
return -1;
}
while (buf.length() == 0) {
try {
wait();
}
catch (InterruptedException ex) {
IOException iox =
new InterruptedIOException();
iox.initCause(ex);
throw iox;
}
}
int cnt = Math.min(len, buf.length());
buf.getChars(0, cnt, cbuf, off);
buf.delete(0, cnt);
return cnt;
}
|
| | |
![]() |
| Bookmarks |
| Seçenekler | |
| |
Benzer Konular | ||||
| Konu | Konuyu açana göre | Forum | Cevap | En Son Mesaj |
| Linux Kurmaya çalışırken D Sürücüm Yokoldu | yediyildizo | GNU / Linux / UNIX / BSD / Pardus | 1 | 13/02/2007 04:52 |
| Windows çalışırken birden restart.??? | kemalkanka | Windows | 12 | 16/12/2006 03:51 |
| Css dosyalarında çalışırken oluşan Dreamweaver Hatası | captainzap | Windows | 1 | 12/10/2006 03:15 |
| Windows çalışırken bir de linux çalıştırmak | nohurge | Windows | 2 | 30/07/2004 18:16 |
| Program çalışırken bileşen oluşturma #KAYNAK# | hmustak | Pascal / Delphi / Delphi.NET | 4 | 14/11/2002 10:10 |
| Reklamlar & Desteklenenler | |
| Hassas Valf | Hassas Kaplama | Antalyamız | Gazete | Ticari Bilişim | Hakan Müştak | Rüya Tabirleri | Kadın | Hastalıklar | Cepte msn ve e-posta | Webmaster | Antalya Aupair | Turkish Property Antalya | Forum | Chat | Perde | Adsl | Araba | bolindir.com | guncelle.com | livescore | Web Tasarım | evden eve nakliyat | forum | evden eve | sohbet | Resimcim| Kalifiye İnsan Kaynakları | Web Tasarım | Oyun | Yusuf KOÇ | Akın Yorulmaz | şiir | UFO | Web Tasarım | Oyunlar | Canlı Tv | |