Client / Server Socket Based Application

Sep 16, 2014

Any example of client/server socket based application using Spring and Maven where application do the following

Client sends a request with a path to any file on the server
„h Server reads the file and responds back with the content
„h Client outputs the content to the console
 
I am trying to follow this [URL] ....
 
I am using java 6

View Replies


ADVERTISEMENT

Client And Server - Reading From Socket

Jul 22, 2014

So we have a Client and Server. Client opens a socket to Server, server initiates new Thread to handle the communication with client. Is there a way to be singnalled when there is input on socket, so I don't have to use infinite while loop solution?

View Replies View Related

Using Socket And JSP For Web-based Chat Application

Feb 13, 2014

I am new to JSP !! and I'm developing a web-based chatting system using JSP and socket.

The problem I am facing is that the sender can send message but on the receiver side we have to manually refresh the page. The sender stays into blocking mode until the receiver refresh its page !

After that I've implemented auto-refresh on the receiver side and "Connection Refused" exception is generated.

View Replies View Related

Java Socket - Client-server Communication Stuck With Multi-threading

Feb 6, 2015

Firstly, my code is just a demo of my multiplayer game (2 or more players can play simultaneously) to demonstrate my problem without any extra things. I have successfully implemented peer-to-peer (P2P) communication in my game. Later, I decided to add support for client-server communication (ie a central server which is also a player) in my game. It should be much easier than P2P. Now here is the problem:

Suppose, I have 1 server and some clients (may be 1 or more clients). They all should give the following output:

Starting...
A
B
C
E
F
...
...
Done!

They all give the above output without using multi-thread. But using multi-threading, it gives the above output only when there're 1 server and 1 client. I'm using 2 threads (1 for sending, 1 for receiving) for each Socket. That means, each client has only 2 threads for communication but the server has (2 * totalClients) threads.

I've attached my full test project. So, here I'm only showing my 2 thread classes.

ReceiveThread class:
class ReceiveThread extends Thread {
private ObjectInputStream receiveStream;
private BlockingQueue<Character> queue = new ArrayBlockingQueue<Character>(Common.totalClients);

[Code] ....

Since I've attached my full test project, I'm not showing the other 3 classes. They are ServerMain, ClientMain and Common. If I've 2 clients to be connected, then I get the following output:

Server: (Runs first)

Starting...
A
Client 1 (clientID is 1): (Runs after the server)

Starting...
A
B
B
Client 2 (clientID is 2): (Runs after Client 1)

Starting...
A

They are stuck at there, even no exception. Actually, the server and the clients are stuck at the line try { ch = queue.take(); } if more than 1 client are connected. It seems that all are trying to receive data. But without using the dedicated threads, they all work as expected even for more than 1 client. Why is this behaviour? How to solve it? Note that I have used the same SendThread and ReceiveThread classes by which I have succcessfully implemented P2P communication.

About my attached test project file:

It has 5 small .java files for the classes as stated above. It is currently faulty when using additional threads. You have to change clientID variable for each client (they are described inside). But it works as expected without additional threads. To test it without the additional threads:

Comment " TODO" linesUncomment the single lines just after " TODO" linesComment the additional thread construction lines (4 lines)

Currently, for a workaround, I'm not using the dedicated threads for sending and receiving data only for client-server communication in my multi-player game. But I'm still using these threads for P2P communication. I don't know why it is and how to solve it.This is the attached test project file as described above.

Attached File(s) : Test Project.zip (4.11K)

View Replies View Related

Obtain Server Specifications Based On Application

Jun 19, 2014

a new java executable file which does heavy processing (batch). Development hasn't really started yet and the design phase is just beginning. Now the client is asking us to give them the minimum server specs to be able to run our application..I'm thinking this can't be done without performance testing, which will be after development. Is there a better and faster way to be able to assess this?

View Replies View Related

Develop Application For Client Server Play Video On Demand

Feb 27, 2014

I want to develop an application for client server play the Video On Demand (VOD).i am new for working on video player. Which library will suitable for this and what methods have to fallow.

View Replies View Related

Swing/AWT/SWT :: Running Application Using Java 1.6 And Windows-based X Server

Apr 15, 2011

At our company we run a third-party Java-based GUI application on one of our Linux server machine, displaying the application to our local Windows work stations using the Cygwin X Server.We noticed a few problems with a new version of this application and was able to narrow it down to the following conditions:

1. Java Swing application running on a UNIX host;
2. Java used is 1.6 (problem not noticed when using Java 1.5)
3. Displaying to Cygwin X server (I've heard other windows-based X servers have the same issue, but I don't have access to any others at this time).

If we run the application natively on Windows, I'm told if the application runs on the Linux host and displays natively to that machine's display there are no problems (although I'm not able to verify this myself).The problems are:

1. Any new frame/dialog is opened in the geographic center of the dual displays, rather than in the middle of one or the other;
2. Any attempt to drag the window to a different location on the display seems to work, but as soon as you let go of the drag, the window snaps back to the original location. This only happens the first time you try to move each window.
3. Drop-down controls (JComboBox, for example) just close back up as soon as you click on them. If you click and drag the mouse to attempt to make a selection, no selection can be made.

Are these known problems using 1.6 on UNIX displaying to Windows-based X Servers?

The only real problem is number 3. I expect that if I put more work into the window placement, I should be able to get past number 1. Number 2 is just a minor annoyance.The following is a simple Java Swing application which when run in the correct environment will exhibit the problems.

import java.awt.EventQueue;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[code]....

View Replies View Related

Authenticate Client Java Application Using ADFS Enabled Sharepoint Server

Feb 21, 2014

I need to authenticate my client java application using ADFS enabled Sharepoint server.

View Replies View Related

Java Socket - How To Set Value Jtext Field When Client Send Message

Apr 26, 2014

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class M_serverApp extends javax.swing.JFrame implements Runnable {

[Code] ....

View Replies View Related

Java Socket - How To Update JTextField When Client Send Message

Apr 26, 2014

Server:

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class M_serverApp extends javax.swing.JFrame implements Runnable {
ServerSocket server = null;

[Code]...

View Replies View Related

Enterprise JavaBeans :: How To Start A Socket Client Connection With EJB3 Timer Bean

May 28, 2013

I have some embedded systems (with web server) putting their states, sensor values into an XML file.

<sensor1>
<temp>21.4</temp>
<unit>°C</unit>
</sensor1>

Now I played a little with EJB3. I want to start a timer bean in a 10second interval which retrieves the IP of registered devices from a databases, opens client sockets with a Thread Pool and retrieves the XML file over HTTP GET of each device listed in the db.

Is it possbile with EJB3? how to start thread based background services like that within EJB3 timer bean?

View Replies View Related

Reading Data From Socket / Responses Of Python Server

Nov 3, 2014

I'm having a lot of problems reading data from a socket. I'm trying to read the responses of a python server. I've a

BufferedReader inputStream = new BufferedReader( new InputStreamReader(socket.getInputStream()));

And then:

char[] messageChunk=new char[32768]; //32768
List<Byte> messageBytesList = new ArrayList<Byte>();
while (inputStream.ready()) {
inputStream.read(messageChunk, 0, 32768);
for(int k=0;k<32768;k++){
messageBytesList.add((byte)messageChunk[k]);
}
}

inside a thread. Then I convert the list of bytes to a byte array using:

Byte[] messageBytes = messageBytesList.toArray(new Byte[messageBytesList.size()]);
byte[] message = ArrayUtils.toPrimitive(messageBytes);

The problem is that I often receive ArrayOutOfBound errors when I try to parse the byte array. I think that I'm reading from the socket in a wrong way..

View Replies View Related

Server Socket Channel - Listen On A Port For Incoming Connections

Dec 3, 2014

What is the difference between instansiating a ServerSocket and .accept(); and a ServerSocketChannel .accept();

They both listen on a port for incoming connections so what is the benifit or dissadvantage of ServerSocketChannel?

View Replies View Related

Deploying JNLP Application In WebSphere Application Server

Mar 11, 2014

I am new to work on JNLP program. I have created a SWING program, JNLP file when i deploy the ear file i am getting 404 error. Please find the steps in details.

1.Created a dynamic web project JWStartProject in eclipse

2.Create a HelloWorld.java class under default package.

import javax.swing.*;
public class HelloWorld extends JFrame {
private static final long serialVersionUID = 4968624166243565348L;
private JLabel label = new JLabel("Hello Java Web START!");
public HelloWorld() {
super("Jave Web Start Example");
this.setSize(350, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
this.setLayout(null);

[Code] ....

Now I exported this project as JWStartProject.war contains following code.

Created Server in Websphere Admin console

Deployed this war file under the server and started.

I have added MIME types also.

I am unable to launch the application. I am getting 404 errors. May I know where I went wrong?

View Replies View Related

Web Services :: Invoke Client From Webapp Based On Some Scheduler

Nov 21, 2014

I need to invoke a restful webservice Client(Rest) from my Webapp based on some scheduler . Also I need to persist the data which the webservice returns in response. So basically-

1. Scheduler triggers, I need to build the rest service request (JSON) and invoke it.
2. Capture the response of the webservice and persist the data in DB.

Technical stack used- Spring MVC

View Replies View Related

Testing TCP Client And Server

Oct 22, 2014

I am attempting to test a TCP Client and Server for an assignment I am doing in class. The goal here is to "test your client and Server applications by transferring (i) a file having 10,000+ lines (see supplied big-file1.txt having 12000+ lines), (ii) a file having 20,000+ lines (you may create one of your own from big-file1.txt, or obtain a large size file from the Google website at [URL] ...). Then, compute and display the total transfer time of the files at both of the sides separately (your choice in millisecond/second)."

I have created the TCPClient and TCPServer java classes, ran the server first and then the client, and using mathematical formulas to calculate the transfer time. Trouble is, I'm having trouble testing the client and server in the file area and not the area where I had to input a line, let the server print it, and then have the client eliminate the articles from the line. I need testing the file. Here is my code so far:

TCPClient:

package tcpclient;
import java.io.*;
import java.net.*;
public class TCPClient {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
String sentence;

[code] ....

How to fix the code so that the time in seconds does not output as 60 for both files and that the files go through the exchange?

View Replies View Related

Client / Server Using PIPE Line?

Apr 20, 2015

I have a program using Pipe line to exchange the infomation in the Client-Server model. Can I separate out main function and then put into Server main and Client main?

//PipeEchoServer
public class PipedEchoServer extends Thread {
PipedInputStream readPipe;
PipedOutputStream writePipe;
PipedEchoServer(PipedInputStream readPipe, PipedOutputStream writePipe){
this.readPipe = readPipe;

[code]....

View Replies View Related

How To Add Server Client Relation In Program

Feb 17, 2014

I have to develop a code in parallel which is implemented in sequential yet. How to add the server client relation in the program so that work can be divided into multiple clients.

View Replies View Related

Sending Message From One Client To Another Via Server?

Apr 2, 2014

I've just recently started playing around with network programming in Java, and I've come up with a simplistic server than can handle multiple clients and return the IP and port each one is connected to (or I'm under the impression that is so). What I've been requested to do as an exercise by one of the programming teachers at my high school (I'm not in a class, this is my own time) is send a message from one client to the other through the ServerSocket so that it may "watch" everything going on. I'm not sure how to go about this at all.

EDIT : now it never seems to go the the else or else if statements...

That is now the main problem. It never, ever, goes past the first if statement, no matter what it is.

EDIT : Okay, I haven't changed a line of code but suddenly not a single if statement is working. They just stopped. The client simply hangs and I can't type anything.

Server

public class Server implements Runnable {
Socket clientSocket;
Server(Socket clientSocket) {
this.clientSocket = clientSocket;
}
public static void main(String args[]) throws Exception {
ServerSocket ssock = new ServerSocket(3480);
System.out.println("Listening on port 3480");

[code]....

View Replies View Related

RMI / How Can Client Send A Message To Server

Sep 3, 2014

I have a problem on how to make my client to send the object to a server.

So I have one interface called "RMIInterface" and client "RMIClient" and server "RMIServer":

RMIInterface
interface RMIInterface {
public String getMessage(String text) throws RemoteException;
}
RMIClient
public class RMIClient {

[code]....

With this program I can connect to a Server with a Client, and print in Client console a message.But, how can I send message from a client to a server, and print that message in server console output?

make the simpliest example with sending a message to a server, edit inteface header code to public interface RMIInterface extends Remote, I forgot to add.

View Replies View Related

Client Info On Server Side

Apr 6, 2014

I want to ask that, when a server listen to A port and it accepts a request from a client then the server accepts the request using accept method,but how does the server get the info about the client like wat is the port no and ip address of the client,I read a answer regarding this that Server never gets the port no of client only the ip address and it connects to client using a connection stream but as far I know from networking, a device must have the ip address and port no of the device it wants to connect to.

View Replies View Related

EJB / EE :: SSL Works Only If Client And Server Are At Same Host

Jun 9, 2014

I have gf 4.0.1 and swing client. I want to get EJB over SSL. I've set all certificates. However, I can get it work only when client and server are at the same host. What I see in tcpdump when they are at the same host:

10.0.17.2.48524 > 10.0.17.2.3820: Flags [P.], cksum 0x378f (incorrect -> 0xf2b6), seq 399:756, ack 1085, win 273, options [nop,nop,TS val 347297976 ecr 347297966], length 357
13:01:26.334898 IP (tos 0x0, ttl 64, id 51559, offset 0, flags [DF], proto TCP (6), length 665)
10.0.17.2.3820 > 10.0.17.2.48524: Flags [P.], cksum 0x388f (incorrect -> 0x626d), seq 1085:1698, ack 756, win 273, options [nop,nop,TS val 347297977 ecr 347297976], length 613

[code]...

View Replies View Related

Running Server And Client From Two Different JButton

Mar 10, 2014

I am looking to run Server and Client from two different JButton.

When I click on start Server button, the server starts to run but I cannot click on start Client button to start the client. Here the code for server:

Java Code:

public void actionPerformed(ActionEvent e) {
Client c = new Client();
c.run();
} mh_sh_highlight_all('java');

View Replies View Related

Simple Server / Client Chat

Dec 28, 2014

I've been trying to create a server/client chat program, but I keep running into areas where I'm not really sure how to work it. I've run into a wall where my client just sits and spins instead of working. URL.... I can work out the dynamic parts later, I just want to understand the meat and potatoes of reading from sockets and writing to sockets (and how to do both at the same time).

View Replies View Related

SSL Client / Server Mutual Authentication

May 2, 2015

I'm trying to build a SSL mutual authenticating private server. I'm not sure what keystores, truststores, or certificates I need to accomplish this. I made keystores for both programs using:

keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048

The server starts up fine, but when I run the client they both give errors.

Server code:

System.setProperty("javax.net.ssl.keyStore", "CLA.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
SSLServerSocketFactory sslServerSocketfactory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
SSLServerSocket sslServerSocket = (SSLServerSocket)sslServerSocketfactory.createServerSocket(9090);
SSLSocket s = (SSLSocket)sslServerSocket.accept();
BufferedReader in =
new BufferedReader(new InputStreamReader(s.getInputStream()));

[code]...

View Replies View Related

RMI With Doing Calculations Across A Server / Client Platform

Apr 6, 2014

It's an RMI program that has to be able to return the mean, mode and median of a set of numbers.It's composed of 4 classes; a client, an implementation class (with the math), an Interface, and a server class.

import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.io.*;
 
[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved