0

I´m trying to open a tcp socket from a j2me midlet on a symbian device to a windows (C#) socket server. The server is working and was tested for months. Now when I try to open a socket from the midlet

clientSocketConnection = (SocketConnection) Connector.open("socket://" + ip + ":" + port);

it just times out with a -34 error (Could not connect).

I know the phone has network capabilities and permissions as I can open such socket connections between 2 phones (emulated) using "ServerSocket" on one side and in the same machine the server is on.

Somehow the J2ME Socket is not compatible with the C# counterpart....

listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

Any hint on this matter would be really appreciated. Also, should I use another type of socket on the server side? I could not find information about the AdressFamily, SocketType nor ProtocolType for the J2ME sockets.

Adding info due to the recent comments. It´s not a firewall problem as I have no firewall and DMZ is configured for the machine ip. The phone (emulated) has access to internet and when I open a socket from an emulator to another, both on the same machine, using my WAN PUBLIC ip on the "client" side to find the "server" side it works.

  • 1
    Its not likely "J2ME Socket is not compatible with the C# counterpart" You must have some other problem. Most likely a Windows Firewall error or other network security problem. – CrazyDart Sep 02 '11 at 18:30
  • Put the `socket://ip:port` into the browser of that phone and see what happens (-34 / could not connect is my guess) – KevinDTimm Sep 02 '11 at 18:35
  • @CrazyDart It´s not a firewall problem as I have no firewall and DMZ is configured for the machine ip. I actually can see the outgoing connection attemp of the emulator with a network monitor and the server is accepting conections from a test utilty on a pc outside the local net. Thx for the comment anyway. – TigerShark Sep 02 '11 at 19:33
  • @KevinDTimm Tried doing that (although I didn´t understand what for) and it just said "Page not found. Check web address". Real webs are working on the phone (emulator), they allways were. Thx for the comment. – TigerShark Sep 02 '11 at 19:40

1 Answers1

0

Well it´s solved now. Really weird but binding a j2me listening port (ServerPort) on "localhost" it´s not the same as binding a .net listening port on "localhost". I mean, when I made a "server" midlet listening on localhost the clients could connect, but when I did it on the .net server they couldn´t. The "solution" was to hardcore the computer ip instead of using "localhost". I really do not understand why, but this worked...

  • This is because in windows you bind to an adapter. Localhost is a different adapter and network stack than say your "local network connection #1" with an IP. Its like opening the door from the living room to the basement and not understanding why the pizza man cant come in the front door. – CrazyDart Sep 07 '11 at 18:00