Help Needed Client Server Paradigm
Hi everybody,
I am trying to make a server that will broadcast a message on the lan and get the reply from a client, but at the stage where I am know I am stuck with the broadcasting part
here is my code, so if anybody can help please do ...
import java.net.*;
import javax.swing.*;
import java.io.*;
import java.awt.event.*;
public class gui {
JFrame frame;
JPanel panel;
JButton button1,button2;
JTextArea area;
JScrollPane pane;
Thread thread;
//MulticastSocket socket;
public static void main(String[] args) {
gui u = new gui();
public gui (){
frame = new JFrame("Broadcast Server");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
panel = new JPanel();
panel.setLayout(null);
area = new JTextArea();
button1 = new JButton("Start");
button1.setBounds(210, 10, 75, 40);
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
(new Thread(new StartServer())).start();
panel.add(button1);
button2 = new JButton("Stop");
button2.setBounds(300, 10, 75, 40);
button2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
area.append("Server is stopped\n");
thread.interrupt();
// socket.close();
button1.setEnabled(true);
button2.setEnabled(true);
panel.add(button2);
pane = new JScrollPane(area);
pane.setBounds(10, 60, 365, 250);
panel.add(pane);
frame.add(panel);
frame.setSize(400, 400);
frame.setVisible(true);
public class StartServer implements Runnable
private static final String 10.0.0.1 = null;
public void run()
try {
// private long FIVE_SECONDS = 5000;
protected DatagramSocket socket = null;
// DatagramSocket socket = new DatagramSocket();
socket = new DatagramSocket(4445);
byte[] buf = new byte[256];
String FirstContact;
FirstContact = "Hello";
buf = FirstContact.getBytes();
InetAddress group = InetAddress.getByName("10.0.0.1");
DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4445);
socket.send(packet);
//area.append("Hello from a thread!\n");
area.append("Server is started\n");
I am getting this exception
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at gui.main(gui.java:21)
EmilKTH wrote:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: You're trying to run a program that doesn't even compile yet.
Step back a step and look at the output of the compiler and scan the errors it reports. Fix those before you try to run your code.
Edit: and in the future, please use the code tags when posting code (simply select your code and push the CODE button just above the text area).
Similar Messages
-
Desperately need some help with client-server java programming
Hi all,
I'm new to client server java programming. I would like to work on servlets and apache tomcat. I installed the apache tomcat v 5.5 into my machine and i have sun java 6 also. I created a java applet class to be as a client and embed it into an html index file, like this:
<applet code="EchoApplet.class" width="300" height="300"></applet>However, when I try to run the html file on the localhost, it print this error: classNotFoundException, couldn't load "EchoApplet.class" class. On the other hand, when I open the index file on applet viewer or by right clicking, open with firefox version 3, it works.
I thought that the problem is with firefox, but after running the applet through the directory not the server, i found that the problem is not any more with firefox.
Can anyone help me to solve this problem. I'm working on it for 5 days now and nothing on the net helped me. I tried a lot of solutions.
Any help?arun,
If the browser is going to execute $myApplet, first it must get the $myApplet.class from the server, right?
So it follows that:
1. $myApplet.class must be acessible to server, and
2. the server must know exactly where to find $myApplet.class
So, the simplest solution is to is put the $myApplet.class in the same directory as the HTML file which uses it... then your applet tag is simple:
<applet height="200" width="400" code="$myApplet.class" ></applet>* The height & width attributes are required
* Note the +.class+ is required in the code attribute (a common mistake).
* This works uniformly (AFAIK) accross all java-enabled browsers.
* There are incompatibilities with the codebase attribute. Poo!
Cheers. Keith. -
Need Help for client - server - client question [Sockets]
Hi
I have read the http://java.sun.com/docs/books/tutorial/networking/sockets/index.html tutorial and made this Knock Knock Application.
But now, I want that one client can view all the other clients which are connected to the server, and interract with a selected cleint over the server (client - server - client).
But I have no idea how to build such a registration concept?
A concrete hint (or link) how to realise this would be very helpful. I searched all the internet for examples, but I dont found a simple example.
Thanks in advance
greedswSam,
It appears that Sun considers RMI to be simpler, although less efficient than the alternative:
http://java.sun.com/developer/technicalArticles/ALT/sockets/
This article also talks about object serialization, which I am a fan of. Suppose that you want to send a data structure containing lots of information (like all connected users). You can actually pass an object (rather than text) across the network using ObjectOutputStream and receive it on the other end with ObjectInputStream. You might create your own Command class for passing objects between the client and server instead of using RMI. The Command class might hold flags that indicate which method should take place on the remote machine (i.e. send chess move command). -
Need help clarifying client/server TNS communication
Im trying to get a clearer understanding of service/listener registration in the Oracle client/server architechure. Feel free to point out errors in my understanding.
When an Oracle client connects to the server, it forms its connect descriptor based on the clients tnsnames.ora file. The client then checks the specified port on the host in the connect descriptor for a listener that is registered with the service defined in the
(CONNECT_DATA =
(SERVICE_NAME = TESTSERVICE)
portion of the client's tnsnames file. Correct?
Does the listener gets its list of SIDs its registered with from the SID_LIST section of the listener.ora file or the tnsnames file?
If the listener gets its list of SIDs to register with from the tnsnames file, is that the tnsnames file on the server?
If so, then what is the SID_LIST used for in the listener.ora file?
Im trying to connect the dots and any help would be much appreciated.
Thanks,Reading below documents would help you understand how client/server TNS communication works:-
Listener Architecture
http://download-east.oracle.com/docs/cd/B14117_01/network.101/b10775/architecture.htm#sthref445
Configuring Naming Methods
http://download-east.oracle.com/docs/cd/B14117_01/network.101/b10775/naming.htm
Configuring and Administering the Listener
http://download-east.oracle.com/docs/cd/B14117_01/network.101/b10775/listenercfg.htm -
Hi guys, ive been developing a scrabble application lately, i have finished most parts of the game itself, so i decided to include the client/server (playing over LAN.)
I have been able to make some features work like chat, update scores, switch turns.
Now, i want to make a move so when a player plays, the tiles he drops on the board would update on the other player's game screen. I created a method and i have tried it in the normal game class(not client/server) and it works. But after coming up wiv a logic to send message to update the tiles, it doesnt work. I have attached pieces of the code pertaining to my problem.
// Method to transfer the tiles (update the board with the tiles)
//LetterBag class:
public void transferTile(int tileindex, int cellindex, JPanel cell[]){
for(int i=0;i<cell.length;i++){
if(i==cellindex){
// letterTile class contains all the tiles with each having its own index value (letterTile extends JLabel)
//tiles is a Vector where i stored all the gameTiles.
letterTile lt=(letterTile) tiles.elementAt(tileindex);
cell.add(lt);
removeTile(tileindex);
Multiplayerboard class:
//Where i send the message to the server
for(int i=0;i<ogaTile.size();i++){
Vector v=(Vector)ogaTile.elementAt(i);
int tindex=(Integer)v.elementAt(0);
int cellindex=(Integer)v.elementAt(1);
client.sendMessage("#-TRANSFERTILES-"+tindex+"-"+cellindex+"-*");
//Tried printing out the above code and it prints out the right values
Multiplayerclient class:
lbag=new LetterBag();
//multiplayer = new MultiplayerBoard(Player, this, chatter);
//This is where the message is interpreted
if (line.startsWith("#-TRANSFERTILES-")) {
//anlyzer is the message string ( message line spits at"-")
int x=Integer.parseInt(analyzer[0]);
int y=Integer.parseInt(analyzer[1]);
//multiplayer is instance of MultiplayerBoard class
//cell is the gameboard panel in MultiplayerBoard class
multiplayer.lbag.transferTile(x, y, multiplayer.cell);
The problem is when i play, the game other client's application update the board with the tiles. I dont know where the problem is coming from maybe the logic or something else. Please any help/suggestion is really needed.dnt worry..
jst solved it.. was an error on ma part -
Hi aggain,
And here is my Client part of program
Server part is in topic "help with client server1
CLIENT.JAVA
import java.io.*;
import java.net.*;
import java.lang.*;
import javax.swing.*;
public class Client {
private static int SBAP_PORT = 5555;
private static String server = "localhost";
public static Socket socket = null;
//main starts
public static void main(String[] args) {
try { //handle broken connection
//set up connection to server, input, output streams
try {
socket = new Socket(server, SBAP_PORT);
// handle wrong host/port errors
catch (UnknownHostException e) {
System.out.println("Unknown IP address for server.");
System.exit(0);
} //end catch UnknownHost
catch (IOException ex) {
System.out.println("No server found at specified port.");
System.exit(0);
} //end catch IOException
catch (Exception exc) {
System.out.println("Error :" + exc);
System.exit(0);
} //end cath Exception exc
InputStream input = socket.getInputStream();
OutputStream output = socket.getOutputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
PrintWriter writer = new PrintWriter(output);
while (true) {
String client_in = JOptionPane.showInputDialog(null, "Client Request");
System.out.println("Sending: " + client_in);
writer.print(client_in);
writer.flush();
//read server entry and dispay
String response = reader.readLine();
if (response == null || response.equals("QUIT"))
System.out.println("No data received");
else
System.out.println("Receiving: " + response);
} //end try
catch (IOException e) {
System.out.println("Connection with server broken:" + e);
System.exit(0);
} //end catch IOException
catch (Exception exp) {
System.out.println("Error :" + exp);
System.exit(0);
} //end catch exp
}//end main()
}//end class Clienthttp://forum.java.sun.com/thread.jspa?threadID=574466&messageID=2861516#2861516
-
HELP:USING CLIENT SERVER PROGRAM ON DIFF.MACHINES CONNECTED TO INTERNET?
BELOW IS THE JAVA CODE FOR CLIENT & SERVER PROGRAM (TCP) USING SOCKET.
I AM TRYING TO RUN CLIENT & SERVER PROGRAM ON 2 DIFFERENT MACHINES CONNECTED 2 INTERNET
(1 RUNS SERVER.java & OTHER CLIENT.java).
IS IT POSSIBLE WITH THE CODE WRITTEN BELOW?
// Server.Java
import java.net.*;
import java.io.*;
class Server {
public static void main(String[] args) {
boolean finished = false;
try{
ServerSocket listener = new ServerSocket(4444);
while(!finished)
{Socket to_client = listener.accept();
OutputStream out = to_client.getOutputStream();
PrintWriter pout = new PrintWriter(out, true);
pout.println("Hello! this is server talking to you.");
to_client.close();
listener.close();
}// end of try
catch(Exception ie) {
System.out.println(ie);
//Client.Java
import java.net.*;
import java.io.*;
class Client
public static void main(String[] args)
Socket client;
String host="serverpcname";//host is assigned name of the server
try
{InetAddress adressen = InetAddress.getByName(host);
client = new Socket(adressen,4444);
BufferedReader scanf = new BufferedReader(new
InputStreamReader(client.getInputStream()));
String someString = scanf.readLine();
System.out.println("From Server: "+someString);
client.close();
catch(Exception e)
System.out.println(e);
WHEN THE CODE IS EXECUTED(CLIENT.java ON 1 PC & SERVER.java on other) IT GIVES FOLLOWING EXCEPTIONS:
java.net.UnknownHostException: serverpcname: serverpcname
PLZ. GUIDE ME.
THANKS IN ADVANCE.For a server to be accessible on the inetrnet it needs to have an externally visible IP address. For example, an address which starts with 192.168.1 is for internal use only can only be used by other machines on the same internal network. The server's firewall needs to allow the port you are using access and the client has to be able to lookup up the IP address either using the hosts file or via a DNS service. None of these things have anything to do with Java programming, so if you have any more questions I sugegst you try googling them or ask a forum which relates to these issues.
The connection time out is due to the fact that there is no way to contact an inetrnal address over the inetrnet. The host unknwown means you haven't configured your PC to lookup that address. i.e. the host is unknown. -
Asalam-o-Alikum!
I m writing client server project. In that project there are many classes that are being used in both (client application and server application). Im using JCreator and also netbeans 5.5 IDE. Plz anyone can help that should i design 1 project for cilent and server. or 2 different projects 1 for client and 1 for server. If i have to use 2 different projects than how can I make available those classes to both projects (client and server) that are being shared by client and server. and i have to make 1 project than how can i run both client and server separately.
thanks in advance.Aslam-o-Alikum!
I am designing a new project that depends on another project. I want to use the classes made in previous project into my new project. Someone (as above) has told me to make the jar file of that class and set the class path to that jar file. Anyone can further tell me that how can set the class path of that project into my new project. And how to import the classes from that project that i have made previously???
Example:
I am designing project name "A" and i have to use a class "b" that not the part of project "A". But actually it is part of project "B". That i have made previously. Please tell how this can be achieved? making jar file of project "B" is right answere then how can i set the path of project "B" in project "A". and how to import class "b" into project "A". I am using JCreator pro 4.0
This is the summary of obove posts. so plz dont read above posts just read this and plz help me if u could.
Plz reply me with a simple example.
Thanks in advance...! -
Help with client server chat 1
Hi,
I have to create small multithreaded client/server. chat program. Server and client have to exchange messages using input boxes until user types QUIT. I did most of it(I think) but it seems that server does not receives client messages and input boxes are displayed only once. I can�t figure out what is the problem. Here is what I did .I know it�s not easy to understand somebody else�s code, but if anybody have some spare time?
this is just a server part, client is in second posting
SERVER.JAVA
import java.io.*;
import java.net.*;
import java.lang.*;
import javax.swing.*;
public class Server
final int SBAP_PORT = 5555;
//constructor
public Server(){
//set up server socket
ServerSocket ss = null;
try {
ss = new ServerSocket(SBAP_PORT);
} //end try
catch (Exception e) {
System.out.println("Could not create socket: Exception " + e);
System.exit(0);
} //end catch
//chat with the client until user break the connection or enters QUIT
try {
while(true) {
System.out.println("Server: Waiting for client to connect ...");
Socket currentSocket = ss.accept();
//create a new thread for each connection
new ServerThread(currentSocket);
} //end while
} //end try
catch (Exception e) {
System.out.println("Fatal server error: " + e);
}//end catch
}//end constructor
//inner class ServerThread to handle individual client connections
private class ServerThread extends Thread {
private Socket sock;
private InputStream in=null;
private OutputStream out=null;
private BufferedReader reader = null;
private PrintWriter writer = null;
//constructor
public ServerThread(Socket sock) {
try{
this.sock=sock;
System.out.println("Server: Client connection established");
start();
}//end try
catch (Exception e){}
}//end constructor
public void run() {
try{
in = this.sock.getInputStream();
out =this.sock.getOutputStream();
reader = new BufferedReader(new InputStreamReader(in));
writer = new PrintWriter(out);
while(true) {
String server_response = JOptionPane.showInputDialog(null,"Server Response");
System.out.println("Sending: " + server_response);
writer.println(server_response);
writer.flush();
String line = reader.readLine(); //receives client request
if (line == null || line.equals("QUIT"))
System.out.println("No data received");
else
System.out.println("Received: " + line);
}//end while
}//end try
catch (Exception e) {
System.out.println("Connection to current client lost.");
finally {
try {
sock.close();
}//end try
catch (Exception e) {}
}//end finally
}//end run
}//end inner class ServerThread
//main starts
public static void main(String[] args) {
new Server();
}//end main()
}//end class Serverhttp://forum.java.sun.com/thread.jspa?threadID=574466&messageID=2861516#2861516
-
Help needed with server essentials 2012 R2 client backup failing
Help please. I have installed WSE 2012 R2 on a new Lenovo TS140, everything seems to be working fine (I can map drives, browse folders, copy files back and forth to clients, run the server through dashboard from a client,
run the server through remote desktop from a client, use remotewebaccess etc. But I can't get ANY of my clients to backup to the server. The connector finds the server, installs on the client and the launchpad runs and says 'connected to server',
but when I try to run the backup, it fails after about 30 seconds and says "can't connect to server"... This is all the same on clients that are Win 7 Home, Win 7 Pro, Win 8.1 pro and win 8.1 home, wired and wireless... Have spent about
a week researching, clean reinstalling, examining router config etc... no luck. Any thoughts or direction for help appreciated. I'm not using storage spaces, and have run drive scans which all show healthy drives (1 SDD - OS, and separate HDs for
files and backups...Status is 'no backups available', and no indication of anywhere to check to start, configure or set a backup. Though I do have the "client computer backup tasks" available over in the tasks panel on the right, but that just sets times for backups to
occur.
The system is backing itself up nightly, but no clients.
I have a bunch of things listed on the BPA (probably as I did some tinkering based on other suggestions, and have tried to set up openDNS forwarding etc. I'm not sure how to undo all that, so if a clean install would help I could do that rather
easily..) BPA partial results listed below...
Warning
Network Policy Server (NPS) should be configured to use more secure authentication methods.
Configuration
Warning
All domains should have at least two domain controllers for redundancy
Operation
Error
The PDC emulator master ..in this forest should be configured to correctly synchronize time from a valid time source
Configuration
Warning
All OUs in this domain should be protected from accidental deletion
Configuration
Error
DirectAccess: DirectAccess must be configured to accept client connections
Configuration
Warning
RRAS: IPv4 routing should be enabled on the RRAS server for routing protocols like DHCP Relay, RIP and IGMP to run
Configuration
Warning
RRAS: IPv6 routing should be enabled on the RRAS server for routing protocols like DHCP Relay to run
Configuration
Warning
RRAS: The number of ports available for use by SSTP should be greater than 0
Configuration
Warning
RRAS: The number of ports available for use by L2TP should be greater than 0
Configuration
Warning
RRAS: Only one certificate for IKEv2 should have IP security IKE intermediate in its EKU property
Configuration
Warning
RRAS: The subject name of the certificate to be used for IKEv2 or SSTP must match the name of the RRAS server or the IP address of the external interface of the RRAS server
Configuration
Warning
RRAS: Use authentication protocols that are considered more secure than PAP, CHAP, or MS-CHAPv2
Configuration
Warning
The RD Gateway server SSL certificate must be configured with a valid certificate subject name
Configuration
Error
Use SSL when you use Basic authentication
Security
Warning
Short file name creation should be disabled
Configuration
Warning
Srv.sys should be set to start on demand
Configuration
Warning
Client failback should be enabled for the Netlogon and SYSVOL folders on domain controllers
Configuration
Warning
Namespace root referrals should use the Lowest Cost ordering method on the following DFS namespace:
\\xxx\Shared Folders
Configuration
Error
DNS: The DNS server 208.67.220.220 on Ethernet must resolve names in the primary DNS domain zone
Configuration
Error
DNS: The DNS server 208.67.222.222 on Ethernet must resolve names in the primary DNS domain zone
Configuration
Error
DNS: The DNS server 208.67.220.220 on Ethernet must resolve names in the forest root domain name zone
Configuration
Error
DNS: The DNS server 208.67.222.222 on Ethernet must resolve names in the forest root domain name zone
Configuration -
Need Help of Client/Server Documentation
Hi ,
I am planning to develop an interface for in Java for Cancer Hospital.
I am familier with Java using for GUI. Can some one refer any documentation about how to write server side code, what langagues are required to connect to server. I am planning to use Oracle for my database , but from client side how do i connect to server, etc.,..
Thanks,You might as well write the server side in Java, too. Unless there are special circumstances that require something else -- but you didn't mention anything like that. Asking the server administrator would help. For a start find out about servlets, which are Java for the server side.
-
Need help converting Client-Server to JSP
Hi;
I have a purely data driven, dynamic, meta driven program
in Java 1.4. Runs on almost any SQL database, and the
systems analysts can do most of the programming just by
entering the data. All screens and sql are auto-genned
at runtime.
I was wondering if there was anyone interested in helping
convert to JSP. I would be willing to give part of the
company profits. It is better then me asking a million
questions here, although there are lots of great experts here.
-Trent
Thanks.My personal email address is [email protected] I would love to contact you if you drop me your phone number.
Manohar -
Help with client server program!
OK, I've gotten this far on my own, but now I need a little help. My program is supposed to allow a client to type in a file name in a JTextField and have the server return the file contents. Someone please let me know where I have erred. Below is the code for server.java and client.java. Thanks for your help!
import java.io.*;
import java.net.*;
public class Server
private BufferedWriter output;
private BufferedReader input;
private Socket connection;
String str;
public void runServer ( )
int counter = 0;
try
ServerSocket server = new ServerSocket ( 8189 );
while ( counter < 2 )
connection = server.accept ( );
getStreams ( );
processConnection ( );
closeConnection ( );
counter++;
catch ( IOException ioException )
ioException.printStackTrace ( );
private void getStreams ( ) throws IOException
output = new BufferedWriter ( new OutputStreamWriter ( connection.getOutputStream ( ) ) );
output.flush ( );
input = new BufferedReader ( new InputStreamReader ( connection.getInputStream ( ) ) );
private void processConnection ( ) throws IOException
String fileName = input.readLine ( );
File file = new File ( fileName );
BufferedReader fileInput = new BufferedReader ( new InputStreamReader
( new FileInputStream ( file ) ) );
BufferedWriter writer = new BufferedWriter ( new FileWriter ( file ) );
while ( ( str = fileInput.readLine ( ) ) != null )
output.write ( str );
output.newLine ( );
output.flush ( );
writer.close ( );
private void closeConnection ( ) throws IOException
output.close ( );
input.close ( );
connection.close ( );
public static void main ( String [ ] args )
Server application = new Server ( );
application.runServer ( );
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Client extends JFrame
private JTextField enterField;
private JButton saveButton;
private JTextArea displayArea;
private BufferedWriter output;
private BufferedReader input;
private String message = "";
private Socket connection;
public Client ( )
super ( "Client" );
Container container = getContentPane ( );
JPanel panel = new JPanel ( );
JLabel displayLabel = new JLabel ( "Enter file name to retrieve: " );
panel.add ( displayLabel );
enterField = new JTextField ( 10 );
enterField.setEnabled ( false );
enterField.addActionListener (
new ActionListener ( )
public void actionPerformed ( ActionEvent event )
sendFile ( event.getActionCommand ( ) );
panel.add ( enterField );
saveButton = new JButton ( "Save Changes" );
saveButton.addActionListener (
new ActionListener ( )
public void actionPerformed ( ActionEvent event )
sendFile ( event.getActionCommand ( ) );
panel.add ( saveButton );
container.add ( panel, BorderLayout.NORTH );
displayArea = new JTextArea ( );
container.add ( new JScrollPane ( displayArea ), BorderLayout.CENTER );
setSize ( 500, 400 );
setVisible ( true );
public void runClient ( )
try
connection = new Socket ( InetAddress.getLocalHost ( ), 8189 );
getStreams ( );
processConnection ( );
closeConnection ( );
catch ( EOFException eofException )
System.out.println ( "Server terminated connection" );
catch ( IOException ioException )
ioException.printStackTrace ( );
private void getStreams ( ) throws IOException
output = new BufferedWriter ( new OutputStreamWriter ( connection.getOutputStream ( ) ) );
output.flush ( );
input = new BufferedReader ( new InputStreamReader ( connection.getInputStream ( ) ) );
private void processConnection ( ) throws IOException
enterField.setEnabled ( true );
message = ( String ) input.readLine ( );
while ( message != null )
displayArea.append ( message + "\n" );
private void closeConnection ( ) throws IOException
output.close ( );
input.close ( );
connection.close ( );
private void sendFile ( String message )
try
output.write ( message );
output.flush ( );
catch ( IOException ioException )
displayArea.append ( "\nError writing" );
public static void main ( String [ ] args )
Client application = new Client ( );
application.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
application.runClient ( );Well, where do YOU think you erred?
Are you getting any error messages? If so, what are they?
Are you getting any behavior other than what you expected? If so, what behavior did you expect, and what behavior are you getting instead?
I can't speak for the others, but I'm much more inclined to help if you had at least said something like...
"If I type in the name of a file that doesn't exist, a JPanel pops up with nothing written in it. This is behavior I want. If I type in the name of a file that does exist, a JPanel should pop up with the contents of that file, but unfortunately, it thinks there's nothing in the file. I know my program can at least find the file because I added a routine to write the name of the file within the JPanel if it can find the file."
It is much easier for me to just write my own program to display the contents of a file, than it is for me to read your mind and discover what problems YOU are having with it. -
Help with Client/Server communication
Im working on a project for university, and one aspect of it is downloading files from a remote computer.
The majority of my project so far has been using RMI only, for browsing the remote computer, deleting files, renaming files, creating new directories and searching for files. All of this is done via a GUI client, with a server running on the server machine.
Ive now reached the part where I'll need to implement the downloading of files. I want the user to select a file from within the GUI and click download, and get it off the server.
I dont need any help with event handlers or getting the contents of the remote computer or anything of that sort.
Consider when I have the name of the file that I want to download from the client.
Im having trouble understanding how exactly its going to work. Ive seen examples of file transfer programs where the user types in the name of the file in the command line which they want to download. But my implementation will differ.
Every time the user clicks the button, I have to send to the server the name of a different file which will need to be downloaded.
I imagine in the event handler for the Download button I'll be creating a new socket and Streams for the download of the file that the user wants. But how am I to send to the client a dynamic file name each time when the user tries to download a different file?
I am a bit new at this, and Ive been searching on the forums for examples and Ive run through them, but I think my situation is a bit different.
Also, will RMI play any part in this? Or will it purely be just Socket and Streams?
I'll also develop an Upload button, but I imagine once I get the Download one going, the Upload one should be much harder.
Any ideas and help would be appreciated.Hi
I'm no RMI expert... and I did not understand your question very well....
I think you should do this procedure:
you should send a request for the file from the client to the server . then a new connection between the two machines should be made which will be used to send the file.
by using UDP you will achive it quite nicely...
//socket - is your TCP socket you already use on the client...
//out - socket's output stream
byte [] b=new String("File HelloWorld.java").getBytes();
// you should use a different way for using this rather than using strings...
out.write(b);
DatagramSocket DS=new DatagramSocket(port);
DS.recieve(packet); //the data is written into the packet...on the server side you should...
//socket - is your TCP socket you already use on the server...
//in - socket's input stream
byte [] b=new byte[256];
out.read(b);
/*Here you check what file you need to send to the client*/
DatagramSocket DS=new DatagramSocket(server_port);
byte [] data=//you should read the file and translate it into bytes and build a packet with them
DS.send(packet); //the data is in the packet...This way the server sends the required file to the client .....
I hope it will help, otherwise try being clearier so I could help you...
SIJP -
Hi All,
I have a client needing me to provide a Windows server based solution for their business. I have limited experience with Server 2012, although I have worked with 2008R2 and SBS2011, I am needing some guidance with this 2012 project.
The client has about 8-10 local users who work at one office with an NBN connection, and 2 other locations that have 3-5 users at each location. I am needing to provide them with a server based solution to manage their data, remote access and also their
email. They are also likely to expand to another physical office soon.
I need to provide them with a DC controller, Exchange server and possibly an SQL server in the future. They currently use an Act database, but I have been told that once the database in ACT grows to 4G, a dedicated database is required?
I am currently thinking of having one physical server and virtualising the additional servers on this platform, however I come from a UNIX background and have not virtualised using Hyper V or ESXi before. I have read a little regarding the CLI and GUI Hyper
V options, but I really need advice on what will suit my needs best from someone that has done it.
I am thinking I maybe should recommend one physical machine with Server 2012 Std which, from what I understand, will allow me to install the host hyper V host on the physical machine and then I could possibly install an instance of Server 2012 as
the DC, Exchange and SQL server on one VM licence, however I have read it is not preferred to have the exchange server on the same VM as the DC but have read that limiting the memory usage of Exchange can negate these issues?
I will also need to have a terminal server/RDP session host in there as well which I could maybe use the 2nd VM licence for.
I suppose my question is, considering that I need to end up with a DC, Exchange server, terminal server/RDP session host and possibly a SQL server in the future, am I better off virtualising and running these on a Server 2012 Std licence, that allows a hyper
v host + 2xVM's or should I be splitting these roles up on different physical machines, keeping in mind costs need to be kept to a minimum.
Also I need to consider the Microsoft Office side of things. Is it more financially viable to use office licences and use remote apps from the terminal server, or just purchase Office H&B for the workstations/laptops and have their outlook connected
directly to the exchange server?
I am concerned from the performance viewpoint that if I run the DC/Exchange and SQL from one VM, then the TS/RDP Host from the other VM licence it may be too much for the DC/Exchange/SQL VM to handle.
I have used SBS 2011 in a few locations with Exchange and the SQL and DC roles installed on HP DL and ML gen 8 servers, and although they run a little slow on the console, they seem to serve the network clients fine.
If do end up running on one physical machine the Hyper V host, one VM as a DC, Exchange and SQL server, and the other VM licence as a RDP session host, what sort of spec'd machine would be recommended to be able to do this, keeping in mind
I usually lean towards HP servers.
Anyhow, thx in advance and any comments or suggestions will certainly be appreciated.
MkmHello,
sorry but in your case without the knowledge of all major requirements i would suggest that you or your client contact an expert and not work with the forums to get this amount of information and setup requirements.
Exchange on DCs is NOT recommended, even not from Microsoft. Also it is highly recommended to run at least 2 DC/DNS/GC per domain for failover and redundancy, of course NOT on the same physical machine.
RDS servers should also run on dedicated machines and not be used for anything else.
SQL should also run on a separate server.
You cannot compare SBS version with regular server versions, the concept behind is different.
With that small amount of users you should consider using an Office365 solution where you could use a plan that fits your needs and have just computers for your client employees.
But as stated above therefore you should find an experienced consultant.
Best regards
Meinolf Weber
MVP, MCP, MCTS
Microsoft MVP - Directory Services
My Blog: http://blogs.msmvps.com/MWeber
Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
Twitter:
Maybe you are looking for
-
How do I sync my email between my iPhone and iPad?
How do I sync my email between my iPhone and iPad?
-
Windows 8.1 Lock Screen drops network connectivity when screen locked using Win+L
Hi! I was sent here from Microsoft Community forum. The question is: Since Windows NT 4.0 I'm using Lock Screen to prevent people from accessing my computer when I'm leaving my room. First I was using CTRL+ALT+DEL / Lock Screen, then switched to Win+
-
Is there a size limit for files you want to upload?
I'm trying to upload a file but it doesn't seem to work, it's 111 MB.
-
Problem with ordering prints off iPhoto
Previously I had been able to order prints directly from iPhoto. When I tried today I kept getting the message "review account info", which I did. Billing, shipping, cc info is all correct. When I submit the order I just keep receiving the same me
-
IPhoto Book Themes - Printed Guides
Hi, Many of you are familiar with my rather obsessive site documenting all the different layouts that you can create with each iPhoto book theme: http://www.lizcastro.com/iphotobookthemes I've long thought it would be handy to have a printable versio