×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    86

    client server programming in j2me

    hi,
    I am having one client program running in mobile and i created a server in the desktop.and i tried to send hi message from the client running in the mobile to the server.
    For client i created a socket like this(sample coding given along with the sun java WTK toolkit)
    SocketConnection sc = (SocketConnection) Connector.open("socket://59.144.3.15:5000");
    59.144.3.15 is the ip address of the machine in which my server is running.
    i wrote my server codings in java and the following is the code
    import java.io.*;
    import java.net.*;

    class Server {
    public static void main(String args[]) {
    String data = "Data sent by server to client";
    String line;
    try {
    ServerSocket srvs = new ServerSocket(8080);
    Socket skt = srvs.accept();
    System.out.print("Server has connected!\n");
    InputStream sin = skt.getInputStream();
    OutputStream sout = skt.getOutputStream();

    DataInputStream in = new DataInputStream(sin);
    DataOutputStream out = new DataOutputStream(sout);
    System.out.println("REceievd");
    byte[] buffer = new byte[1024];
    int len;
    while((len = in.read(buffer)) > 0) {
    String req = new String(buffer,0,len);
    System.out.print(req);
    }
    }
    catch(Exception e) {
    System.out.print(e.toString());
    }
    }
    }

    In emulator this program is working fine and i am able to send message from the client to the server.
    I installed my client program in the Nokia6630 mobile and tried to connect to the server,at that time client-server connection itself not establishing.

    Can anyone tell me how to establish a simple client server connection?
    Thanks a lot

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: client server programming in j2me

    hi,

    have you tried on different device (phone)?
    it couuld be service provider issue or access point issue (say you are not allowed to establish persistant socket connection due to service limits put by operator),

    regards,
    Peter

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: client server programming in j2me

    i agree with peter concerning the operator limitation
    did you try to run your server on port 80 ?
    may be the limitation is event worse, like http only, in which case you may need to use a webserver, and webservices

Similar Threads

  1. Replies: 1
    Last Post: 2006-08-21, 08:58
  2. Exchanging data between client and server
    By rihoe in forum Symbian
    Replies: 1
    Last Post: 2005-01-31, 08:25
  3. [BT] Client and Server - Am I Right ??
    By valentin_da_itiv in forum Bluetooth Technology
    Replies: 0
    Last Post: 2003-10-22, 11:14
  4. Replies: 0
    Last Post: 2003-03-03, 12:46
  5. FTP server and J2ME
    By shahzad73 in forum Mobile Java General
    Replies: 0
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •