🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #789

Problem receiving data with a socket client

#789
From: Alejandro Guzman
Date: Wed, 23 Oct 2002 13:42
58 lines
3120 bytes
Hello everyone,  I�m trying to do a socket client application with Jbuilder 6, this app send information to a server  socket (made in Delphi 6), I  don�t have problem sending the information, my problem is receiving the information, because I don�t receive the information, unless  I turn off the server socket, and in this moment I receive the information�. I don�t know what wrong, I did several examples that I found on the internet and all of them give me the same problem�. The following is the source code:

import java.net.*;
import java.io.*;
import java.util.*;

public class Socket_OnLine {
  public static void main(String[] args)
    {
      String Servidor         = "SERVER_NAME";
      int    Puerto           =  1024;
      String mensajeEncrip    = "";
      String mensajeRespuesta = "";
      String respuestaSocket;

      try
        {
          System.out.println("Connecting to " + Servidor + " Port " + Puerto);

          // Abrimos un Socket conectado al servidor y al puerto
          Socket socket = new Socket(Servidor, Puerto);

          // Conseguimos el canal de entrada
          BufferedReader entrada = new BufferedReader(new InputStreamReader(socket.getInputStream()));

         // Conseguimos el canal de salida
          BufferedWriter salida = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));

          mensajeEncrip = "TO8000000007AT00001T";
          salida.write(mensajeEncrip.trim());
          salida.flush();

          // Recogemos la l�nea devuelta por el servidor y la presentamos en la pantalla

//***** THE APPLICATION FREEZE IN THIS LINE *****//              
          mensajeRespuesta = entrada.readLine();

          System.out.println(mensajeRespuesta);

          // Cerramos el Socket
          salida.close();
          entrada.close();
         socket.close();
        }
      catch (UnknownHostException e)
        {
          System.out.println("Entro a la exception de UnknownHostException "+e.getMessage());
        }
      catch (IOException e)
        {
          System.out.println("Entro a la exception de IOException "+e.getMessage());
        }
    }
}

Does any body can help me please�..

Alejandro
Technical Details
Message-ID: <3db6a742$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1089d0,d723ab0dfe9ca972,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-10-23 08:06:08 PST
From: "Alejandro Guzman" <aeguzmanv@hotmail.com>
Sender: "Alejandro Guzman" <aeguzmanv@hotmail.com>
Reply-To: "Alejandro Guzman" <aeguzmanv@hotmail.com>
Subject: Problem receiving data with a socket client
Newsgroups: borland.public.jbuilder.java.api
X-User-Info: 209.124.97.22 209.124.97.22    
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3db6a742$1@newsgroups.borland.com>
Date: 23 Oct 2002 06:42:26 -0700
X-Trace: newsgroups.borland.com 1035380546 207.105.83.65 (23 Oct 2002 06:42:26 -0700)
Lines: 59
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!newsgroups.borland.com!not-for-mail