Send Single File From A Client To Default Directory Of Server
Aug 8, 2014
I'm trying to do a program that send a single file from a client to a default directory of a Server. The program use the datagramSocket and datagramPacket for the transfer via UDP. The client sent the packet of the file correctly and the server start the receiving but every time the Server class crashes after it's receiving 4/5 packet (exactly 8192 byte)
Then i put the code of the 2 class and the 2 output.
OUTPUT CLIENT:
PROGRAM TRANSFER PACKAGES
name of file is : Doc1.pdf
his dimension: 11408 byte
*** start sending
- 1024 byte
- 2048 byte
- 3072 byte
- 4096 byte
- 5120 byte
- 6144 byte
- 7168 byte
- 8192 byte
- 9216 byte
- 10240 byte
- 11264 byte
- 11408 byte
*** FILE SUCCESFULL SENDED***
BUILD SUCCESSFUL (total time: 3 seconds)
OUTPUT SERVER
PROGRAM TRANSFER PACKAGES
START NEW CONNECTION
Directory: C:prova
Server waiting in port: 9876
Waiting Client...
Name of file is : Doc1.pdf
Dimension : 11408
[Code] ....
In this point the program go in loop and didn't anything. I don't understand how can i resolve it...
SERVER
package udp_pacchetti;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
[Code] ...
View Replies
ADVERTISEMENT
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
Jun 14, 2014
What is the best way to send an arrayList from the server to the client? ObjectInputStream and ObjectOutputStream?
View Replies
View Related
Jan 22, 2015
I want to send a message to a specific client in a server. This is my code and what I tried(I have only given you 3 classes in which I believe I have the problem).
TextClient:
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class TextClient {
public TextClient() {
[Code] .....
View Replies
View Related
Jul 6, 2014
I write a Client/Server program,trying to send and receive a object between client and server. I use the ObjectStream but there exists an EOFException on the client side when invoking readObject() .... I've tried many times but couldn't figure it out ...
server-side code
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try{
ObjectOutputStream out = new ObjectOutputStream(resp.getOutputStream());
ObjectInputStream in = new ObjectInputStream(req.getInputStream());
PersonalData pe = (PersonalData)in.readObject();
System.out.println(pe.getYearlySalary());
[Code] .....
View Replies
View Related
Mar 4, 2015
I am creating a server that stores application updates. When the client connects the server send the update. The server is sending the file but the file is not complete, i.e, if the file is 317kb,its send 117kb. Below is the code I am using :
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class TestFileServer {
[Code] ....
What could the problem be?
View Replies
View Related
Jan 22, 2015
I want to send a message to a specific client in a server. This is my code and what I tried(I have only given you 3 classes in which I believe I have the problem).
TextClient:
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class TextClient {
public TextClient() {
[Code]...
View Replies
View Related
Jan 30, 2014
I have programmed a Router class which has two methods, receive and send.In receive method it receives the plain text from the server through port 2000.Its now all cool.In send method it sends the message to a client through the port 2001 but at the client i get an exception
connection refused:connect
import java.io.*;
import java.util.*;
import java.net.*;
import java.sql.*;
class Router {
String str;
public void receive()
[code]....
View Replies
View Related
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
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
Aug 11, 2014
I'm new to json and the web. My purpose is to use json data from a server and parse it and show meaningful data to the user. I am aware of json parsing, so no sweat there. However, I would like to know how json data is sent to the front end after which it can be parsed.
Usually in my json parsing examples, I have a variable like var data = ]OR I do a getJSON on a data.json file which I have stored in the project folder. However, I want this data to come real time from a servlet. How to go about this?
So, basically my question is, how do I send real time json data from a servlet backend, say some records which I have extracted from the database using jdbc?
View Replies
View Related
Aug 13, 2014
Using Java 7 update 5 (I know it's old...), we are trying to send concurrent requests to a RMI Server. When we start to tamp up the load (not too much - up to 50 concurrent requests) we start to see many IO Problems like Broken Pipe and Connection Reset By Peer. Could we be hitting some unknown limitation on concurrent access? Is there such limitation?
View Replies
View Related
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
Jan 8, 2015
I want to understand how is it possible to send data (image + text) along a single form. Here is my code:
<form method="post" action="updateAccount"
encType="multipart/form-data">
<input type="file" name="file" value="Select image ..." /> <input
type="submit" value="Start Upload" /> <br>
<textarea rows="8" cols="54" name="about">Yes
View Replies
View Related
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
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
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
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
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
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
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
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
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
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
Dec 6, 2014
So i wrote this text to try and create a simple chat program that does the following: Prepend names to messages, announce entrance and exit of chat, display user list, and share a whiteboard.So far the Server seems to be working but the Chat Client is throwing errors at me left and right..
CURRENT ERROR:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:Windowssystem32>cd..
C:Windows>cd..
C:>Usersjaydesktopchat
'Usersjaydesktopchat' is not recognized as an internal or external command,
operable program or batch file.
[code]....
View Replies
View Related
Apr 3, 2014
I'm working on an assignment right now which involves passing a variable series of numbers to the Server to be sorted into the correct order and returned to the client.
So far I have it connecting to the server and asking for my numbers, and I am entering each number and pressing return, and it is accepting each number individually.
One (smaller I think) problem i'm having is with the client code, specifically the while loop.. I've tried to code it so that when I enter a full stop ('.') the program will stop asking me for more numbers and move on to sending them to the server.. but instead it just crashes giving an error.. heres an example
"Enter a number: 1
Enter a number: 3
Enter a number: 2
Enter a number: 1.
java.lang.NumberFormatException: For input string: "1."
at java.lang.NumberFormatException.forInputString(Num berFormatException.java:65)
[Code] ....
Here's the client code in full
package numberSortprogram;
import java.io.*;
import java.net.ServerSocket;
public class NumSortClient {
public static void main(String[] args) {
InputStreamReader is = new InputStreamReader(System.in);
[Code] ....
The big problem that I have is figuring out how to send the sorted array back to the client..
So, what im trying to get to happen is-
-Client is asked to enter numbers
-Client enters series of numbers into an array
-Array is converted to a string and sent to the server
-String is then split into an array of strings and sorted using compareTo (don't know if this is the best way?)
-Sorted array is sent back to client and displayed.
fyi this is making use of streamsockets..
All of the rest of my code is below:
package numberSortprogram;
import java.io.IOException;
import java.net.*;
import java.util.regex.PatternSyntaxException;
public class NumSortServer {
public static void main(String[] args) {
int serverPort = 4444; // default port
if (args.length == 1 )
[Code] .....
View Replies
View Related