"Connection refused" is telling you something very important: there's no
socket waiting for connection on the port that you specify. I don't see
anything necessarily wrong with your Java code (it's been a long time since
I did that sort of thing in Java, though). You really need to sniff the
packets and just make sure that what you think is happening is really
happening. If the exception is correct, you should see a packet from the
Java end with the SYN bit set. The response packet from the PDA should have
the RST bit set. This may be repeated several times before the Java code
takes the hint and declares that the connection was refused.
Can you ping the PDA from the PC where the Java code will run? At a guess,
I'd say that there's either not real network connectivity between your PC
and the PDA, maybe because there's a proxy that is actually connecting stuff
outside the GPRS network to stuff inside it or something.
I don't see anything wrong with the .NET CF code. It works fine on an
Ethernet network for me, although you haven't done a good job of making
stopping it work very well.
Paul T.
"Izaskun" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> wrote in message news:<(E-Mail Removed)>...
>> How is the PC making the connection? What's the IP address of the PDA?
>> How
>> is the PC getting that information?
>>
>
> 1.- The connection request make in the PC is written in Java:
>
> public class conexion
> {
> public Socket so=null;
> public String host="213.4.169.30";
> public DataInputStream input=null;
> public DataOutputStream output=null;
> public int port=14001;
> public conexion()
> {
>
> }
> public static void main(String [] args)
> {
> conexion con= new conexion();
> con.conectar();
>
> }
> public void conectar()
> {
> try {
> so= new Socket (host,port);
> input = new DataInputStream(so.getInputStream());
> output = new DataOutputStream(so.getOutputStream());
> if (so != null && input != null && output != null) {
> output.writeBytes("TEST,....\n");
> String response="";
> response = input.readLine();
> System.out.println("Server: " + response);
> output.close();
> input.close();
> so.close();
>
> }
> }
> catch (UnknownHostException e)
> {
> e.printStackTrace();
> }
> catch (IOException ioe)
> {
> ioe.printStackTrace();
> }
> }
> }
>
> And when it try to connect with the IP address return an exception:
> java.net.ConnectException: Connection refused: connect at
> java.net.PlainSocketImpl.socketConnect(Native Method)
>
> 2.- The IP address of the PDA is assigned dinamically by the mobile
> company.
>
> 3.- I'm still in test phase, so I write the IP address directly in the
> Java source code.
>
> Thanks
|