• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

client server programming in j2me

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your server a publically available server with that IP address? Also in the J2ME code you say it used port 5000, but in the java code it says port 8080.

Mark
 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
yes it is public server only.in my program i used the same port number only.
i checked once again also.while posting the question i mistyped the port number.
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi lakshmi,

How did you make your server publicly available?
 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i hosted my server program and running that program in a remote system.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic