I want to create java server socket and j2me client socket which can communicate with each other.
Does anyone know how to do this?
Are you trying to share data between two MIDlets running on one mobile phone?
Are you trying to exchange data between a mobile phone and a remote server?
Have you read the documentation for the javax.microedition.io package?
Related
i have a good experience of socket programming in java using lan cable but I'm unable to find anything regarding the wireless transfer using java
plz help me out
Start here.
TCP or UDP can be used. TCP establishes a secure connection between the computers and ensures the delivery of the packages. UDP sends the package and it could be received or not. TCP is the most commonly used of the two, but UDP is mainly used for multiplayer video games.
Sending data over lan wirelessly should still work using sockets.
I want to know how to share a socket single connection between two clients. I have programmed in the following way, and need advise for the rest of the development.
Socket (Java desktop program)
|
|
|<---------------------->|
| |
iOS Mobile client Java Applet (Runs on desktop where same Socket is there)
Steps are,
1. Java Applet connect with this socket and gets a random number from this socket, in the very first call. It is developed.
[Socket program accepts client and creates a Thread and runs ]
2. I have a text field in iOS Mobile client where user will type that random number (shared the rand number via phone or chat) which it got from that Applet. It is developed.
3. iOS Mobile client sends this random number and also get it connected with socket. It is developed.
4. I need to share images from iOS client to Applet now via this socket established.
I want to know, how to make the 'Applet connection with socket' and 'iOS client with socket' to be in the same connection, so that I can share images from iOS app to Applet via this socket connection? Can a single socket connection be shared between two clients (iOS and Applet) like this?
Please advise me, how can i achieve the 4th point mentioned above with the same connection established between two clients.
Thank you!
There is no connection between the iOS client and the applet.
While you could try to establish a connection between the two, it's probably better for your server (the Java desktop program) to act as a proxy sending images received from the iOS client on one socket to the applet on the other socket.
I want to create an application which will connect to a file server and download a few video files. The server is a shared hosting Linux server.
I don't want code or anything like that, I just want to know whether this is possible and if so, what should I be researching. Should I be using java sockets? Or can Java sockets only connect to java based servers?
Should I be using java sockets?
Depends on the type of server you connect to. You can use an existing library which will abstract the interaction with the server for you (recommended) or implement the required protocol yourself (not recommended).
Can Java sockets only connect to java based servers?
Sockets in Java are just an interface to the native socket API of the OS you are on. Every program that connects to a server over the network has to use them, regardless of whether it is a C/C++/Python/Java/... application. So, to answer your question; no, "Java sockets" can connect to any server.
Read more about sockets in this Wikipedia article about sockets in general or this one about Berkeley sockets (the socket API implemented by most operating systems).
I'm developing a chat application in Java that enables client to connect to a predefined port and when two clients are connected the server should connect those two sockets and data should be exchanged between them.
I know to create a ServerSocket and Socket that will connect and establish a communication between them through a separate port and a server socket. But, how can I connect those two connected clients?
If you are creating a chat application then Chat server will not connect client socket in order to communicate.
You can try following approach:
On server side Use a HashTable to store connected clients.
When you receive a message from client, include a an id of CLient to whom message is to be sent and simply pass on the message to other client.
There will be separate threads running for these clients, so you need to have a policy to control the load on server.
This questions sounds like a homework assignment.
If you would like to see a great contemporary demo of a chat system you may learn from Play's WebSocket chat sample application.
How can I run a simple Java client on Eclipse. I have written a small server code to run on an Android phone. It is supposed to receive strings from a PC client (running Java) and do some specific tasks accordingly. I have successfully tested my server code on Android, but I'm not sure how to configure Eclipse for running client side application. I'm using port 4444 for socket communication. How to make my client running on eclipse to listen to a specific port (4444).
I want to connect my PC client and Android phone over WiFi hotspot (simple communication based on private IP address). Please help!
The socket code is new Socket("the ip address", 4444); If you are only writing strings, I would recommend attaching a PrintWriter to the socket's outputstream (and a scanner or BufferedReader for reading strings).