Bir C sunucusundan bir Java istemcisine bir dizi dize (char ** topics
) göndermeye çalışıyorum. Görünüşe göre, sunucu konuları doğru bir şekilde gönderir, ancak istemci bunları almaz.C sunucusundan Java istemcisine ileti gönderme
/* SERVER */
while (*topics != NULL) {
printf(" > Sending topic '%s'.. ", *topics);
if(write(sd, *topics, sizeof(*topics)) == -1) {
perror("write");
exit(1);
}
printf("[OK]\n");
topics++;
}
istemci şuna benzer:
/* CLIENT */
static void server_connection() {
String topic = null;
try {
Socket _sd = new Socket(_server, _port); // Socket Descriptor
// Create input stream
DataInputStream _in = new DataInputStream(_sd.getInputStream());
BufferedReader _br = new BufferedReader(new InputStreamReader(_in));
System.out.println("s> Current Topics:");
while ((topic = _br.readLine()) != null) {
System.out.println(topic);
}
if(topic == null) {
System.out.println("Not topics found");
}
// Close socket connection
_out.close();
_in.close();
_sd.close();
} catch(IOException e) {
System.out.println("Error in the connection to the broker " + _server + ":" + _port);
}
}
istemci
s> Current Topics:
gösterir ve bekliyor kalır ...:/
C. 'dekieof işlevini okumak isteyebilirsiniz C. – Olaf
C sunucusu akış üzerinde yeni satır karakteri mi gönderiyor? Java'da 'readLine' engelleniyor. – rgettman
"\ n" konusunu konunun sonuna kadar birleştirmeyi denedim, ancak hala aynı – nash