Client and Server socket connection - java

I'm new in java, and I have a problem. I have two android phones (Client and Server). Can anybody say me how to display on Client application the Server IP address?

Kryonet is a very good Java library which provides a clean and simple API for efficient TCP and UDP client/server network communication using NIO. It works on Android as well.
It will make your network programming work a lot more easier, and you can get a better understanding of how to write client and server side code.
I would suggest that you try out your network programming skills using this library.
You need not even hard code any IP address of the server while in LAN. The clients can discover the server in just one line of code.

Related

Java. Communicate two peer-to-peer applications

I am studying communications in Java using RMI and in all the references that I find there is a client that makes calls to remote methods in a server.
That is, all communications are initiated by the client.
If I wanted two computers to communicate as equals, would it be right for each of them to implement a remote object? That is, the two applications would play the role of client and server.
Thank you
If you are creating desktop application, you could use sockets for communications between many computers.
A socket is one end-point of a two-way communication link between two or more programs running on the network. Socket classes are used to represent the connection between a client program and a server program. More.
Example code for server/client applications
You should know that you will need a bit of knowledge about concurrency and networking to create good communication between many computers. Creating simple server/client applications is very good way to achieve it :)
Please remember that client will always need IP:PORT address to connect to server.

Java Server and client/ RMI or Socket?

I'm developing a Desktop LAN base java server and client application
where a Client must login and also to pass some data to server.
assuming i have 10 clients that inserting record simultaneously to server.
which is the best approach in this kind of situation, should I use RMI for login and record insertion? or Sockets?
if sockets please provide a key idea for me to start with.
key points to consider
-Multithreading
-able to send back data on client
If you want to connect your server via internet (and/or firewalls) it is probably a hassle to do this with plain RMI. In the past I have used Java Simon for such tasks which is very easy to implement. However if you plan to support other clients than Java clients, then you should have a look at Apache Thrift or Google Protocoll Buffers

Need to migrate from Java socket to Xmpp communication of my chat application

Need to migrate from Java socket to Xmpp communication of my desktop chat application.
I got a api called SMACK for that but for that I have to use Openfire server i.e I can only code in my client. But I have my own socket server which I am using for my current chat application. Is there a way to use that server and write XMPP specific code in server?? basically reuse the socket server..?
I have written the code using SMACK which calls the server but how to make the server listen to that?
You would have to make your server understand and respond to the XMPP protocol. In other words, you would have to write an XMPP server, which makes no sense when you can simply use one of many existing ones. Using smack doesn't require you to use Openfire, but it is one of many options available.

networking in java for client server communication

I need to make a troubleshooting tool in java
From the java code, I need to communicate with tethereal (linux commands) to help me generate a .pkt file. The .pkt file will contain all the contents of the communication that took place between the client and the server- i.e. all the packet communication between the client and server.
how should I do that?
Do you know WireShark? That is a cross-platform Network Packet Capturing application.
The idea is that it captures all packets (TCP and UDP) that passes one network device (eg: WiFi card) and you apply a filter on the port that your application uses, and eventually an IP address. Very useful tool.
If you really need to do it in java you can use http://jnetpcap.com/ which is a wrapper for libpcap which works similar to tethereal.

Java Sockets Client-Server application

I Am trying to code a java program with sockets in which i have 3 system(1 server and two clients) both the clients connect to the server at the same port.Its a file transfer program.
Now my requirement is that both the connection would remain active throughout and as soon as client1 writes to its socket connection on the server the server relays that data to the socket between server and client2.
How can i achieve this?
There are TONES of client/server chat examples out there for many different languages. All of them are fairly similar.
Try Google Java client/server chat tutorial. Here's one if you couldn't find an example.
http://inetjava.sourceforge.net/lectures/part1_sockets/InetJava-1.9-Chat-Client-Server-Example.html
Jinith: transferring a file is not that different from sending text over a socket. Do you have any specific requirements for how the clients know to get data? Are you familiar with blocking/nonblocking/asynch sockets? Comfortable using threads?

Categories

Resources