Problem with client\ server program
hello,
i have two programs one client and the other is server but i can't connect between client and server
how can i connect between client and server ??
this programs run in jbuilder
what type of client u r using.WHich server u r using to run u r programs.If u r client and server is simple java client then u can use Socket to client to server.Otherwise u can use jsp/servlet to connect to the app /web server comm'n
Anand
Similar Messages
-
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. -
Problems with games server and client
Hi! I am making an MMORPG game and I have problems with the server and client connection.
I can connect to the server, but when a second player does, the server console tells me this:
java.net.SocketException: Connection reset
After that, all clients disconnect.
Which is the problem?
How can I solve it?
Thank you so muchHere is how my sever work. I took some of this code from a book called Killer Programming Games in Java. If you google for it, you will find it for sure.
TourGroup tg = new TourGroup(); // this object stores information about all clients connected to the server
try {
ServerSocket serverSock = new ServerSocket(PORT);
Socket clientSock;
while (true) {
System.out.println("Waiting for a client...");
clientSock = serverSock.accept();
new TourServerHandler(clientSock, tg).start(); // this is the thread that monitors each client
catch(Exception e)
{ System.out.println(e); }
} This is some code of TourServerHandler
public TourServerHandler(Socket s, TourGroup tg)
this.tg = tg;
clientSock = s;
name= "?";
cliAddr = clientSock.getInetAddress().getHostAddress();
port = clientSock.getPort();
System.out.println("Client connection from (" +
cliAddr + ", " + port + ")");
public void run()
// process messages from the client
try {
// Get I/O streams from the socket
BufferedReader in = new BufferedReader(
new InputStreamReader( clientSock.getInputStream() ) );
PrintWriter out =
new PrintWriter( clientSock.getOutputStream(), true );
// and here goes the rest... The TourServerHandler thread uses this code to send messages:
tg.broadcast(msg); tg.broadcast works like this:
synchronized public void broadcast(String cliAddr, int port, String msg)
// broadcast to everyone but original msg sender
TouristInfo c; // this object stores info about the client
for(int i=0; i < tourPeople.size(); i++) {
c = (TouristInfo) tourPeople.get(i);
c.sendMessage(msg);
} This is the error part
public void sendMessage(String msg)
PrintWriter out;
out.println(msg);
System.out.println("OK");
} I can't find any error but I still get that Connection reset exception... -
Exchange Server 2010 SP3 - Rollup 8 - Issue - Problems with client connections - MS Outlook 2013
Exchange Server 2010 SP3 - Rollup 8 - Issue - Problems with client connections - MS Outlook 2013
Detected Problems:
- Access denied for attached mailbox (department mailbox)
- Access denied for delete or move messages on own mailbox
- Can't send new messages with error (Error: [0x80004005-00000000-00000000])
Solution:
- Rollback to Exchange 2010 SP3 - Rollup 7
- You can rollback to Exchange 2010 SP3 - RollUp 7 in 30 min
Algunos de los destinatarios no recibieron su mensaje.
Asunto: Hola
Enviado el: 11/12/2014 8:35
No se puede localizar a los destinatarios siguientes:
'[email protected]' en 11/12/2014 8:35
Este mensaje no se pudo enviar. Inténtelo de nuevo más tarde, o póngase en contacto con el administrador de red.
Error: [0x80004005-00000000-00000000].See the following forum thread:
https://social.technet.microsoft.com/Forums/en-US/1be9b816-b0ab-40ea-a43a-446239f8eae3/outlook-client-issues-following-exchange-2010-rollup-8 -
Help with MIDlets - TCP client server program
Hi I am new to using MIDlets, and I wanted to create a simple TCP client server program.. I found a tutorial in J2me forums and I am able to send a single message from server(PC) to client(Phonemulator) and from client to server. But I want to send a stream of messages to the server. Here is my program and I am stuck in the last step wher i want to send lot of messages to server. Here is my program, Could any one of u tell me how to do it? Or where am i going wrong in thsi pgm?
Code:
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.SocketConnection;
import javax.microedition.io.StreamConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeExcepti on;
public class SocketMIDlet extends MIDlet
implements CommandListener, Runnable {
private Display display;
private Form addressForm;
private Form connectForm;
private Form displayForm;
private TextField serverName;
private TextField serverPort;
private StringItem messageLabel;
private StringItem errorLabel;
private Command okCommand;
private Command exitCommand;
private Command backCommand;
protected void startApp() throws MIDletStateChangeException {
if (display == null) {
initialize();
display.setCurrent(addressForm);
protected void pauseApp() {
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
public void commandAction(Command cmd, Displayable d) {
if (cmd == okCommand) {
Thread t = new Thread(this);
t.start();
display.setCurrent(connectForm);
} else if (cmd == backCommand) {
display.setCurrent(addressForm);
} else if (cmd == exitCommand) {
try {
destroyApp(true);
} catch (MIDletStateChangeException ex) {
notifyDestroyed();
public void run() {
InputStream is = null;
OutputStream os = null;
StreamConnection socket = null;
try {
String server = serverName.getString();
String port = serverPort.getString();
String name = "socket://" + server + ":" + port;
socket = (StreamConnection)Connector.open(name, Connector.READ_WRITE);
} catch (Exception ex) {
Alert alert = new Alert("Invalid Address",
"The supplied address is invalid\n" +
"Please correct it and try again.", null,
AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert, addressForm);
return;
try {
// Send a message to the server
String request = "Hello\n\n";
//StringBuffer b = new StringBuffer();
os = socket.openOutputStream();
//for (int i=0;i<10;i++)
os.write(request.getBytes());
os.close();
// Read the server's reply, up to a maximum
// of 128 bytes.
is = socket.openInputStream();
final int MAX_LENGTH = 128;
byte[] buf = new byte[MAX_LENGTH];
int total = 0;
while (total<=5)
int count = is.read(buf, total, MAX_LENGTH - total);
if (count < 0)
break;
total += count;
is.close();
String reply = new String(buf, 0, total);
messageLabel.setText(reply);
socket.close();
display.setCurrent(displayForm);
} catch (IOException ex) {
Alert alert = new Alert("I/O Error",
"An error occurred while communicating with the server.",
null, AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert, addressForm);
return;
} finally {
// Close open streams and the socket
try {
if (is != null) {
is.close();
is = null;
} catch (IOException ex1) {
try {
if (os != null) {
os.close();
os = null;
} catch (IOException ex1) {
try {
if (socket != null) {
socket.close();
socket = null;
} catch (IOException ex1) {
private void initialize() {
display = Display.getDisplay(this);
// Commands
exitCommand = new Command("Exit", Command.EXIT, 0);
okCommand = new Command("OK", Command.OK, 0);
backCommand = new Command("Back", Command.BACK, 0);
// The address form
addressForm = new Form("Socket Client");
serverName = new TextField("Server name:", "", 256, TextField.ANY);
serverPort = new TextField("Server port:", "", 8, TextField.NUMERIC);
addressForm.append(serverName);
addressForm.append(serverPort);
addressForm.addCommand(okCommand);
addressForm.addCommand(exitCommand);
addressForm.setCommandListener(this);
// The connect form
connectForm = new Form("Connecting");
messageLabel = new StringItem(null, "Connecting...\nPlease wait.");
connectForm.append(messageLabel);
connectForm.addCommand(backCommand);
connectForm.setCommandListener(this);
// The display form
displayForm = new Form("Server Reply");
messageLabel = new StringItem(null, null);
displayForm.append(messageLabel);
displayForm.addCommand(backCommand);
displayForm.setCommandListener(this);Hello all,
I was wondering if someone found a solution to this..I would really appreciate it if u could post one...Thanks a lot..Cheerz -
Problem with Application server
Hi All,
I'm facing problem with Application Server. When I installed the appserver and started it.. It started with the message " server has been started and some services will run at back". But when I tried stopping it using the stop default server i got the message that there is no server running but when i saw in the task manager i cud see two process running 1) appserver.exe and 2) imqbroker(something).exe so eventually I had to kill it.
Now when I'm trying to start the application server again its giving me this message "CLI156 Could not start the domain domain1" and below is the log file attached if its of any help
[#|2005-08-31T23:37:57.000+1000|WARNING|sun-appserver-pe8.1_01|javax.enterprise.tools.launcher|_ThreadID=10;|LAUNCHER005:Spaces in your PATH have been detected. The PATH must be consistently formated (e.g. C:\Program Files\Java\jdk1.5.0\bin; ) or the Appserver may not be able to start and/or stop. Mixed quoted spaces in your PATH can cause problems, so the launcher will remove all double quotes before invoking the process. The most reliable solution would be to remove all spaces from your path before starting the Appservers components. |#]
[#|2005-08-31T23:37:57.015+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.tools.launcher|_ThreadID=10;|
C:/Program Files/Java/jdk1.5.0\bin\java
-client
-Xmx512m
-XX:NewRatio=2
-Dcom.sun.aas.defaultLogFile=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/logs/server.log
-Djava.endorsed.dirs=C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/endorsed
-Djava.security.policy=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/server.policy
-Djava.security.auth.login.config=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/login.conf
-Dsun.rmi.dgc.server.gcInterval=3600000
-Dsun.rmi.dgc.client.gcInterval=3600000
-Djavax.net.ssl.keyStore=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/keystore.jks
-Djavax.net.ssl.trustStore=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/cacerts.jks
-Djava.ext.dirs=C:/Program Files/Java/jdk1.5.0/jre/lib/ext;C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/lib/ext
-Djdbc.drivers=com.pointbase.jdbc.jdbcUniversalDriver
-Djavax.management.builder.initial=com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder
-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dcom.sun.enterprise.taglibs=appserv-jstl.jar,jsf-impl.jar
-Dcom.sun.enterprise.taglisteners=jsf-impl.jar
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
-Dcom.sun.aas.configName=server-config
-Dorg.xml.sax.parser=org.xml.sax.helpers.XMLReaderAdapter
-Ddomain.name=domain1
-Djmx.invoke.getters=true
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Dcom.sun.aas.promptForIdentity=true
-Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser
-Dcom.sun.aas.instanceRoot=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1
-Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
-Dcom.sun.aas.domainName=domain1
-Djava.util.logging.manager=com.sun.enterprise.server.logging.ServerLogManager
-Dproduct.name=Sun-Java-System/Application-Server
-Dcom.sun.enterprise.overrideablejavaxpackages=javax.faces,javax.servlet.jsp.jstl,javax.xml.bind,javax.help
-Dcom.sun.aas.configRoot=C:/Program Files/netbeans-4.1/SunAppServer8.1/config
-Djava.library.path=C:\Program Files\Java\jdk1.5.0\jre\bin\client;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\Java\jdk1.5.0\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Sun\AppServer\bin;;C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\jre\jdk1.5.0\bin;.;
-Dcom.sun.aas.instanceName=server
-Dcom.sun.aas.processLauncher=SE
-cp
C:/Program Files/Java/jdk1.5.0/lib/tools.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/appserv-rt.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\admin-cli.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-admin.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\dom.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jmxremote.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jmxremote_optional.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jsf-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jsf-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\rmissl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xalan.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xercesImpl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-upgrade.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-ext.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\j2ee.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\activation.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-cmp.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-jstl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\commons-launcher.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\commons-logging.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\j2ee-svc.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jax-qname.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxr-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxr-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxrpc-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxrpc-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\mail.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\relaxngDatatype.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\saaj-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\saaj-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xsdlib.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/install/applications/jmsra/imqjmsra.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/imq/lib/jaxm-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/imq/lib/fscontext.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/ant/lib/ant.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/pointbase/lib/pbclient.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/pointbase/lib/pbembedded.jar
com.sun.enterprise.server.PEMain
start
display
native|#]
[#|2005-08-31T23:38:03.515+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.resource.jms|_ThreadID=10;|JMS5023: JMS service successfully started. Instance Name = imqbroker, Home = [C:\Program Files\netbeans-4.1\SunAppServer8.1\imq\bin].|#]
[#|2005-08-31T23:38:03.515+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.system.core|_ThreadID=10;|CORE5098: AS Socket Service Initialization has been completed.|#]
[#|2005-08-31T23:38:15.796+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.system.tools.admin|_ThreadID=10;|ADM0001:MBeanServer initialized successfully|#]
[#|2005-08-31T23:38:16.484+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.system.core.security|_ThreadID=10;|SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.|#]
[#|2005-09-01T00:48:45.484+1000|WARNING|sun-appserver-pe8.1_01|javax.enterprise.tools.launcher|_ThreadID=10;|LAUNCHER005:Spaces in your PATH have been detected. The PATH must be consistently formated (e.g. C:\Program Files\Java\jdk1.5.0\bin; ) or the Appserver may not be able to start and/or stop. Mixed quoted spaces in your PATH can cause problems, so the launcher will remove all double quotes before invoking the process. The most reliable solution would be to remove all spaces from your path before starting the Appservers components. |#]
[#|2005-09-01T00:48:45.531+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.tools.launcher|_ThreadID=10;|
C:/Program Files/Java/jdk1.5.0\bin\java
-client
-Xmx512m
-XX:NewRatio=2
-Dcom.sun.aas.defaultLogFile=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/logs/server.log
-Djava.endorsed.dirs=C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/endorsed
-Djava.security.policy=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/server.policy
-Djava.security.auth.login.config=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/login.conf
-Dsun.rmi.dgc.server.gcInterval=3600000
-Dsun.rmi.dgc.client.gcInterval=3600000
-Djavax.net.ssl.keyStore=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/keystore.jks
-Djavax.net.ssl.trustStore=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/cacerts.jks
-Djava.ext.dirs=C:/Program Files/Java/jdk1.5.0/jre/lib/ext;C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/lib/ext
-Djdbc.drivers=com.pointbase.jdbc.jdbcUniversalDriver
-Djavax.management.builder.initial=com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder
-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dcom.sun.enterprise.taglibs=appserv-jstl.jar,jsf-impl.jar
-Dcom.sun.enterprise.taglisteners=jsf-impl.jar
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
-Dcom.sun.aas.configName=server-config
-Dorg.xml.sax.parser=org.xml.sax.helpers.XMLReaderAdapter
-Ddomain.name=domain1
-Djmx.invoke.getters=true
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Dcom.sun.aas.promptForIdentity=true
-Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser
-Dcom.sun.aas.instanceRoot=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1
-Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
-Dcom.sun.aas.domainName=domain1
-Djava.util.logging.manager=com.sun.enterprise.server.logging.ServerLogManager
-Dproduct.name=Sun-Java-System/Application-Server
-Dcom.sun.enterprise.overrideablejavaxpackages=javax.faces,javax.servlet.jsp.jstl,javax.xml.bind,javax.help
-Dcom.sun.aas.configRoot=C:/Program Files/netbeans-4.1/SunAppServer8.1/config
-Djava.library.path=C:\Program Files\Java\jdk1.5.0\jre\bin\client;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\Java\jdk1.5.0\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Sun\AppServer\bin;;C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\jre\jdk1.5.0\bin;.;
-Dcom.sun.aas.instanceName=server
-Dcom.sun.aas.processLauncher=SE
-cp
C:/Program Files/Java/jdk1.5.0/lib/tools.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/appserv-rt.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\admin-cli.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-admin.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\dom.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jmxremote.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jmxremote_optional.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jsf-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jsf-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\rmissl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xalan.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xercesImpl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-upgrade.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-ext.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\j2ee.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\activation.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-cmp.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-jstl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\commons-launcher.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\commons-logging.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\j2ee-svc.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jax-qname.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxr-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxr-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxrpc-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxrpc-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\mail.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\relaxngDatatype.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\saaj-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\saaj-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xsdlib.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/install/applications/jmsra/imqjmsra.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/imq/lib/jaxm-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/imq/lib/fscontext.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/ant/lib/ant.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/pointbase/lib/pbclient.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/pointbase/lib/pbembedded.jar
com.sun.enterprise.server.PEMain
start
display
native|#]
[#|2005-09-04T04:12:39.281+1000|WARNING|sun-appserver-pe8.1_01|javax.enterprise.tools.launcher|_ThreadID=10;|LAUNCHER005:Spaces in your PATH have been detected. The PATH must be consistently formated (e.g. C:\Program Files\Java\jdk1.5.0\bin; ) or the Appserver may not be able to start and/or stop. Mixed quoted spaces in your PATH can cause problems, so the launcher will remove all double quotes before invoking the process. The most reliable solution would be to remove all spaces from your path before starting the Appservers components. |#]
[#|2005-09-04T04:12:39.343+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.tools.launcher|_ThreadID=10;|
C:/Program Files/Java/jdk1.5.0\bin\java
-client
-Xmx512m
-XX:NewRatio=2
-Dcom.sun.aas.defaultLogFile=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/logs/server.log
-Djava.endorsed.dirs=C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/endorsed
-Djava.security.policy=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/server.policy
-Djava.security.auth.login.config=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/login.conf
-Dsun.rmi.dgc.server.gcInterval=3600000
-Dsun.rmi.dgc.client.gcInterval=3600000
-Djavax.net.ssl.keyStore=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/keystore.jks
-Djavax.net.ssl.trustStore=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/config/cacerts.jks
-Djava.ext.dirs=C:/Program Files/Java/jdk1.5.0/jre/lib/ext;C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1/lib/ext
-Djdbc.drivers=com.pointbase.jdbc.jdbcUniversalDriver
-Djavax.management.builder.initial=com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder
-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dcom.sun.enterprise.taglibs=appserv-jstl.jar,jsf-impl.jar
-Dcom.sun.enterprise.taglisteners=jsf-impl.jar
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
-Dcom.sun.aas.configName=server-config
-Dorg.xml.sax.parser=org.xml.sax.helpers.XMLReaderAdapter
-Ddomain.name=domain1
-Djmx.invoke.getters=true
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Dcom.sun.aas.promptForIdentity=true
-Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser
-Dcom.sun.aas.instanceRoot=C:/Program Files/netbeans-4.1/SunAppServer8.1/domains/domain1
-Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
-Dcom.sun.aas.domainName=domain1
-Djava.util.logging.manager=com.sun.enterprise.server.logging.ServerLogManager
-Dproduct.name=Sun-Java-System/Application-Server
-Dcom.sun.enterprise.overrideablejavaxpackages=javax.faces,javax.servlet.jsp.jstl,javax.xml.bind,javax.help
-Dcom.sun.aas.configRoot=C:/Program Files/netbeans-4.1/SunAppServer8.1/config
-Djava.library.path=C:\Program Files\Java\jdk1.5.0\jre\bin\client;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\Java\jdk1.5.0\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\lib;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\Program Files\netbeans-4.1\SunAppServer8.1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Sun\AppServer\bin;;C:\Program Files\Java\jdk1.5.0\bin;.;C:\Program Files\jre\jdk1.5.0\bin;.;
-Dcom.sun.aas.instanceName=server
-Dcom.sun.aas.processLauncher=SE
-cp
C:/Program Files/Java/jdk1.5.0/lib/tools.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/appserv-rt.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\admin-cli.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-admin.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\dom.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jmxremote.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jmxremote_optional.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jsf-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jsf-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\rmissl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xalan.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xercesImpl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-upgrade.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-ext.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\j2ee.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\activation.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-cmp.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\appserv-jstl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\commons-launcher.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\commons-logging.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\j2ee-svc.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jax-qname.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxr-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxr-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxrpc-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\jaxrpc-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\mail.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\relaxngDatatype.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\saaj-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\saaj-impl.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib\xsdlib.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/install/applications/jmsra/imqjmsra.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/imq/lib/jaxm-api.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/imq/lib/fscontext.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/lib/ant/lib/ant.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/pointbase/lib/pbclient.jar;C:/Program Files/netbeans-4.1/SunAppServer8.1/pointbase/lib/pbembedded.jar
com.sun.enterprise.server.PEMain
start
display
native|#]
[#|2005-09-04T04:13:50.453+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.resource.jms|_ThreadID=10;|JMS5035: Timed out after 60000 milliseconds while trying to verify if the JMS service startup succeeded.|#]
[#|2005-09-04T04:13:50.453+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.resource.jms|_ThreadID=10;|JMS5037: Check permissions of MQ instance directory C:\Program Files\netbeans-4.1\SunAppServer8.1\imq\var\instances|#]
[#|2005-09-04T04:13:50.453+1000|INFO|sun-appserver-pe8.1_01|javax.enterprise.resource.jms|_ThreadID=10;|JMS5036: More details may be available in the log file for the JMS service broker instance imqbroker. Please refer to the JMS provider documentation for the exact location of this log file.|#]
[#|2005-09-04T04:13:50.453+1000|SEVERE|sun-appserver-pe8.1_01|javax.enterprise.system.core|_ThreadID=10;|UnknownException during startup. Disable quick startup by setting system property com.sun.enterprise.server.ss.ASQuickStartup to false
com.sun.appserv.server.ServerLifecycleException: [C4003]: Error occurred on connection creation [127.0.0.1:7676]. - cause: java.net.ConnectException: Connection refused: no further information
at com.sun.enterprise.jms.JmsProviderLifecycle.checkProviderStartup(JmsProviderLifecycle.java:427)
at com.sun.enterprise.server.ss.ASLazyKernel.startASSocketServices(ASLazyKernel.java:54)
at com.sun.enterprise.server.PEMain.run(PEMain.java:274)
at com.sun.enterprise.server.PEMain.main(PEMain.java:220)
Caused by: com.sun.messaging.jms.JMSException: [C4003]: Error occurred on connection creation [127.0.0.1:7676]. - cause: java.net.ConnectException: Connection refused: no further information
at com.sun.messaging.jmq.jmsclient.ExceptionHandler.getJMSConnectException(ExceptionHandler.java:233)
at com.sun.messaging.jmq.jmsclient.ExceptionHandler.handleConnectException(ExceptionHandler.java:180)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.readBrokerPorts(PortMapperClient.java:176)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.init(PortMapperClient.java:101)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.<init>(PortMapperClient.java:54)
at com.sun.messaging.jmq.jmsclient.protocol.tcp.TCPConnectionHandler.<init>(TCPConnectionHandler.java:61)
at com.sun.messaging.jmq.jmsclient.protocol.tcp.TCPStreamHandler.openConnection(TCPStreamHandler.java:102)
at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnectionOld(ConnectionInitiator.java:281)
at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnection(ConnectionInitiator.java:107)
at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnection(ConnectionInitiator.java:92)
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.init(ProtocolHandler.java:613)
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.<init>(ProtocolHandler.java:1194)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.openConnection(ConnectionImpl.java:1894)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.init(ConnectionImpl.java:712)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.<init>(ConnectionImpl.java:293)
at com.sun.messaging.jmq.jmsclient.UnifiedConnectionImpl.<init>(UnifiedConnectionImpl.java:33)
at com.sun.messaging.jmq.jmsclient.QueueConnectionImpl.<init>(QueueConnectionImpl.java:32)
at com.sun.messaging.ConnectionFactory.createQueueConnection(ConnectionFactory.java:72)
at com.sun.messaging.jmq.admin.jmsspi.JMSAdminImpl.pingProvider(JMSAdminImpl.java:783)
at com.sun.enterprise.jms.JmsProviderLifecycle.waitForJmsProvider(JmsProviderLifecycle.java:335)
at com.sun.enterprise.jms.JmsProviderLifecycle.checkProviderStartup(JmsProviderLifecycle.java:396)
... 3 more
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:525)
at com.sun.enterprise.server.ss.ASClientSocketImpl.connect(ASClientSocketImpl.java:175)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:178)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.readBrokerPorts(PortMapperClient.java:156)
... 21 more
|#]
[#|2005-09-04T04:13:50.484+1000|SEVERE|sun-appserver-pe8.1_01|javax.enterprise.system.core|_ThreadID=10;|Exception while stoppping Lifecycle.
com.sun.appserv.server.ServerLifecycleException: MQ startup failed :[C4003]: Error occurred on connection creation [127.0.0.1:7676]. - cause: java.net.ConnectException: Connection refused: no further information
at com.sun.enterprise.jms.JmsProviderLifecycle.checkProviderStartup(JmsProviderLifecycle.java:376)
at com.sun.enterprise.jms.JmsProviderLifecycle.onShutdown(JmsProviderLifecycle.java:445)
at com.sun.enterprise.server.ss.ASLazyKernel.stopLifecycle(ASLazyKernel.java:175)
at com.sun.enterprise.server.ss.ASLazyKernel.stopMQ(ASLazyKernel.java:169)
at com.sun.enterprise.server.ss.ASLazyKernel.exitServer(ASLazyKernel.java:74)
at com.sun.enterprise.server.ss.ASLazyKernel.startASSocketServices(ASLazyKernel.java:67)
at com.sun.enterprise.server.PEMain.run(PEMain.java:274)
at com.sun.enterprise.server.PEMain.main(PEMain.java:220)
|#]
Thanks in advance
AjayThe VERY FIRST message in the server log gives you a hint as to what the problem might be. The server thinks you have spaces in your PATH to the application server. Therefore, the solution is to kill the server however you need to (task manager, whatever) and then reinstall it in a path that doesn't contain spaces. That's the low-hanging fruit here; if that doesn't work, well, then we will have to find some other solution.
-
Client Server program using Applets for client
Creating a client server program using Applets for the clients.
Having problems distrubting the message from client to client
using ObjectOutputStreams/ObjectInputSteams.
I can connect each client to simple server and respond with by writting
the i/o stream of each client but unable to communicate from client to client. If any one out there has in tips of creating a class of objectOutputStreams that holds a array of ObjectOutputStreams and then broadcasts the message to every client, it would be much appreciated
Thanks.Cheers poop for your reply
I never explained the problem properly. What it is I am trying to set up a Client Server program using Applets as the clients GUI. The problem is broadcasting the message to multiply client connnection(s).
Below is code, each client can connect and send message to the server. The problems is broadcasting the message to every client connection. The every client can input a message but only the last connected client can receive the message?????? Thanks in advance..
/*this my server class */
import java.io.*;
import java.net.*;
public class Server extends JFrame
private static final int ServerPort=8080;
private static final int MaxClients=10;
private ObjectOutputStream output=null;
private ObjectInputStream input=null;
private BroadCastMessage broadcastMessage;
public void runServer()
BroadCastMessage broadcastMessage= new BroadCastMessage();
try
{ //connect to server
ServerSocket s = new ServerSocket(ServerPort,MaxClients);
//listen to port 5000 for new connections
///max is 25
System.out.println("Server listening on port "+ServerPort);
while (state.isProgramRunning())
try
/// sGUI.waitForConnection();//new line
s.setSoTimeout(100);
//enable times in server-socket
while (true)
Socket incoming = s.accept();
//wait and accept connnections from serverSocket
//instance of the class,pases the new connection and message
//spawn as a thread
SocketConnection connection=new SocketConnection(incoming,broadcastMessage);
Thread a = new Thread(connection); a.start();
System.out.println(state.getConnectionCount()+"Connection received from :"+incoming.getInetAddress());
catch(InterruptedIOException x){}
while (state.getConnectionCount()>0);
System.exit(0);
}catch (IOException e){}
public static void main(String[] args)
Server s =new Server();
s.runServer();
/*this is my socket connection thread*/
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class SocketConnection implements Runnable
private ObjectOutputStream out;
private ObjectOutputStream output=null;
private ObjectInputStream input=null;
private BroadCastMessage passOnMessage;
private Socket theConnection=null;
private String Inmessage="";
private int Ocount;
public SocketConnection(Socket caller,BroadCastMessage broadcastMessage,Ocount)
theConnection =caller;///(5000,n)
Ocount=ncount;
passOnMessage=broadcastMessage;
public void run()
try
getStreams();
processConnection();
catch(Exception e)
{String clientDetails=("connection from IP Address: "+theConnection.getInetAddress());}
private synchronized void getStreams() throws IOException
{ //get streams to send and receive data
//set up output buffer to send header information
///Ocount++;
//create new objectoutputstream
output=passOnMessage.getOutputObject(output,theConnection,Ocount);
///flush output buffer to send header info.
Ocount++;
//set up input stream for objects
input =new ObjectInputStream(
theConnection.getInputStream());
System.out.print("\nGot I/O streams\n");
private synchronized void processConnection()throws IOException
//process connection with client
String Outmessage =" count : "+status.getConnectionCount();
//send connection successful message to client
Outmessage=Outmessage+"SERVER>>>Connection successful";
output.writeObject(Outmessage);
output.flush();
do ///process messages sent from client
try
Inmessage = (String) input.readObject();
System.out.println(Inmessage);
/* //while the connection is open each line
that is passed from the client to the server
is read in and is displayed*/
messageDetails.setMessage(Inmessage);
String CurrentMessage=messageDetails.getMessage();
//output.writeObject(CurrentMessage);
// output.flush();
passOnMessage.FloodMessage(CurrentMessage);
//sending out the message
catch(ClassNotFoundException classNotFoundException){}
}while (!Outmessage.equals("CLIENT>>>TERMINATE"));
/*this my attempt at broadcasting the message to all clients
my thinking was that you could create a array of objectoutputstreams
which in turn could be broadcasted(bit confussed here)*/
import java.io.*;
import java.net.*;
public class BroadCastMessage /// implements Runnable
private int count;
private String Inmessage="";
private ObjectOutputStream temp=null;
private ObjectOutputStream[] output = new ObjectOutputStream [12];
//temp level of array of objects
public BroadCastMessage()
count=0;
public synchronized void FloodMessage(String message) throws IOException
System.out.print(count);
for(int i=0;i<count+1;i++)
try
{ System.out.print(count);
output[count].writeObject(message);
output[count].flush();
catch(IOException ioException)
{ioException.printStackTrace();}
notifyAll();
public ObjectOutputStream getOutputObject(ObjectOutputStream out,Socket caller,int Ocount)
try
{ temp = new ObjectOutputStream(caller.getOutputStream());
AddObjectOutputStream(temp,Ocount);
////FloodMessage();
catch(IOException ioException)
{ioException.printStackTrace();}
return temp;
public void AddObjectOutputStream(ObjectOutputStream out,int Ocount)
{ ///add new object to array
count=Ocount;
output[count]=out;
System.out.print("\nthe number of output streams : "+count+"\n");
} -
Design Pattern for multithreaded client server program
I asked this question in another post, but with other stuff, so I'll distill this one.
I am creating a multi-threaded client server program (just for learning - a chat program at this point). I built the server and client in swing, and I'm wondering what the best design pattern is for this setup. Right now all the swing stuff is in the MyServer class. In that class I have a loop accepting client connections to the serverSocket and creating a new MyServerThread (threaded client connection).
The problem is that all the work of creating input streams, interacting with the server, all that stuff is done in the MyServerThread class, but I want that text to be written up to the Swing objects - which is in the MyServer class. So right now in the MyServerThread class I pass the MyServer object into it, but I'm not sure if that is really the most robust thing to do. Does anybody have any suggestions as to how this should be done. If somebody has an article they'd like to point to I'll check it out too. But if it's just the run-of-the-mill multithreaded client-server article, I've read alot and most don't specifically address my question.Thanks for the reply Kaj, and I think I'll keep my design for now, since it's just quick and dirty. I've read the MVC concept a while ago and I'll revisit it again when I get more serious. But I have a question, why should I be using a callback interface, why an interface at all? And then make MyServer implement that interface...why not just pass MyServer to the thread object? Or is there something down the line that I did not forsee?
-
About the communication issues in the client-server program
About the communication issues in the client-server program
Hi, I have some questions about the communication issues in a java project, which is basically the client and server architecture. In brief, the client, written in java, can be deployed anywhere, and in the following part, assume it is in the LAN (Local Area Network) which is connnected to the internet through the firewall and/or proxy, and the server, written in
java too, simply provides the listening service on a port in a remote machine. And assume the server is connected to the internet directly so that the scenario can be simple to focus on the core questions.
My questions are as follows:
1 About the relationship between the communication port and protocol
Generally, protocols at the application level like HTTP, FTP have their own default port, e.g., HTTP is corresponding to 80,
FTP is to 25. But it is NOT necessary for the web server to provide the HTTP listening service at port 80, right? E.g, Tomcat provides the HTTP listening service at 8080. So it means the default relationship between the application protocl and their port is some routine, which is not necessary to follow, right?
2 Assume a LAN connected to the internet through a proxy, which only allows HTTP protocol, then questions are:
2.1 Does the proxy recognize the HTTP request from the client by the port number (carried in the request string)? For example, when the server provides the HTTP listening service at 80, then the request from the client will include the port number 80, then the proxy will parse such info and decide if or not the request can be out.
2.2 Does the proxy recognize the HTTP request from the client by protocol (carried in the request string)? For example, the protocol used in the communicatin should be included in the request, then the proxy can parse it to make the decision.
3 In java programm, if using the HTTP protcol, then on the client: the corresponding API is java.net.URLConnection, right?
If using the TCP protocol directly, then on the client:the corresponding API is java.net.Socket, right? In both cases, the server side use the same API, java.net.ServerSocket?
Is it correct to say that the communication by Socket is faster than URLConnection?
4 Take MSN messenger for example, which protocol does it use? Since proxy configure is only the possible option, so I guess generally the TCP protocol is used directly so that the better perfomrance can be achieved, right?
5 Given 3 computers within the same LAN, can the client, proxy, server environment above be correctly simulated? If so, can
you recommend me some typical proxy program so that I can install it to configure such an enviroment to perform some test?
6 I guess there should be some software to find out which port number a given program/process is going through to connect to
the remote machine, and which port number a given program/process is listening on? Also, what protocl is used in the given
communication.
7 Finally, regarding each of the above questions, it will be highly appreciated that if you can recommed some references,
tutorials, books etc. In summary, what I care about is how to enable the java client behind the proxy and firewall to
communicate with the remote server without problems, so if you know some good tutorials plz let me know and thx in advance!
Finally, thanks for your attention so such long questions =).FTP is to 25. But it is NOT necessary for the web
server to provide the HTTP listening service at port
80, right? E.g, Tomcat provides the HTTP listening
service at 8080. So it means the default relationship
between the application protocl and their port is
some routine, which is not necessary to follow,
right?Not sure what you're saying here.
There must be a server listening on some port. The client must know what port that is. If you open the connection using the Socket class, you'll explicitly specify the port. If you use some higher level class like URLConnection or something in the commons Net package, there's probably a default port that will be used if you don't explicitly specify another.
There's no way for the client to know that the HTTP request will go to port 80 instead of port 8080. If you think the the client contacts the server without explicitly naming a port, and then asks the server "get me your HTTP server", and the port is determined from that, you're mistaken.
Not sure if you're thinking that, but it sounded like you might be.
2 Assume a LAN connected to the internet through
a proxy, which only allows HTTP protocol, then
questions are:
2.1 Does the proxy recognize the HTTP request
from the client by the port number (carried in the
request string)? For example, when the server
provides the HTTP listening service at 80, then the
request from the client will include the port number
80, then the proxy will parse such info and decide if
or not the request can be out. I'm not sure, but I think most proxies and firewalls are configured by ports. I thought I'd heard of more sophisticated, higher-level ones that could understand the content to some degree, but I don't know anything about those.
3 In java programm, if using the HTTP protcol,
then on the client: the corresponding API is
java.net.URLConnection, right?That's one way.
You might want to look into this:
http://jakarta.apache.org/commons/httpclient/
If using the TCP protocol directly, then on the
client:the corresponding API is java.net.Socket,
right? In both cases, the server side use the same
API, java.net.ServerSocket? A Java client will user Socket, and a Java server will use ServerSocket and Socket.
Is it correct to say that the communication by Socket
is faster than URLConnection?Probably not. -
Hello,
I have an issue with connecting client SB1H on Windows, the scenario is as follows:
1.- Server:
Suse Linux Enterprise Server 11.3 kernel version: 3.0.76-0.11 IBM
NDB and Server are review 69 SP06
2.- Client:
Windows 8 Pro Virtual Machine on Microsoft Hyper-V
SB1H PL 11 version 32bits
SAP HANA Studio version 1.0.60
When I run SB1H the following message appears:
There is a problem with the server's security certificate. The security certificate is not from a trusted certifying authority. SAP Business One is unable to connect to the server.
Any idea what could be the solution?Hi,
Please check SAP notes:
1993392 - Server components setup wizard: New default values for certificates and single sign-on option
1929288 - Do not configure SSL for XApp during installation or upgrade if XApp is installed on a different machine than the SAP HANA server
Thanks & Regards,
Nagarajan -
File transfer, read write through sockets in client server programming java
Hello All, need help again.
I am trying to create a Client server program, where, the Client first sends a file to Server, on accepting the file, the server generates another file(probably xml), send it to the client as a response, the client read the response xml, parse it and display some data. now I am successful sending the file to the server, but could not figure out how the server can create and send a xml file and send it to the client as response, please help. below are my codes for client and server
Client side
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
public class XMLSocketC
public static void main(String[] args) throws IOException
//Establish a connection to socket
Socket toServer = null;
String host = "127.0.0.1";
int port = 4444;
try
toServer = new Socket(host, port);
} catch (UnknownHostException e) {
System.err.println("Don't know about host: localhost.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to host.");
System.exit(1);
//Send file over Socket
//===========================================================
BufferedInputStream fileIn = null;
BufferedOutputStream out = null;
// File to be send over the socket.
File file = new File("c:/xampp/htdocs/thesis/sensorList.php");
// Checking for the file to be sent.
if (!file.exists())
System.out.println("File doesn't exist");
System.exit(0);
try
// InputStream to read the file
fileIn = new BufferedInputStream(new FileInputStream(file));
}catch(IOException eee)
System.out.println("Problem, kunne ikke lage fil");
try
InetAddress adressen = InetAddress.getByName(host);
try
System.out.println("Establishing Socket Connection");
// Opening Socket
Socket s = new Socket(adressen, port);
System.out.println("Socket is clear and available.....");
// OutputStream to socket
out = new BufferedOutputStream(s.getOutputStream());
byte[] buffer = new byte[1024];
int numRead;
//Checking if bytes available to read to the buffer.
while( (numRead = fileIn.read(buffer)) >= 0)
// Writes bytes to Output Stream from 0 to total number of bytes
out.write(buffer, 0, numRead);
// Flush - send file
out.flush();
// close OutputStream
out.close();
// close InputStrean
fileIn.close();
}catch (IOException e)
}catch(UnknownHostException e)
System.err.println(e);
//===========================================================
//Retrieve data from Socket.
//BufferedReader in = new BufferedReader(new InputStreamReader(toServer.getInputStream()));
DataInputStream in = new DataInputStream(new BufferedInputStream(toServer.getInputStream()));
//String fromServer;
//Read from the server and prints.
//Receive text from server
FileWriter fr = null;
String frn = "xxx_response.xml";
try {
fr = new FileWriter(frn);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
try{
String line = in.readUTF(); //.readLine();
System.out.println("Text received :" + line);
fr.write(line);
} catch (IOException e){
System.out.println("Read failed");
System.exit(1);
in.close();
toServer.close();
public class XMLSocketS
public static void main(String[] args) throws IOException
//Establish a connection to socket
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(4444);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(1);
Socket clientLink = null;
while (true)
try
clientLink = serverSocket.accept();
System.out.println("Server accepts");
BufferedInputStream inn = new BufferedInputStream(clientLink.getInputStream());
BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:/xampp/htdocs/received_from_client.txt")));
byte[] buff = new byte[1024];
int readMe;
while( (readMe = inn.read(buff)) >= 0)
{ //reads from input stream, writes the file to disk
ut.write(buff, 0, readMe);
// close the link to client
clientLink.close();
// close InputStream
inn.close();
// flush
ut.flush();
// close OutputStream
ut.close();
//Sending response to client
//============================================================
//============================================================
System.out.println("File received");
}catch(IOException ex)
{System.out.println("Exception.");}
finally
try
if (clientLink != null) clientLink.close();
}catch(IOException e) {}
clientLink.close();
//serverSocket.close();
}SERVER
import java.net.*;
import java.io.*;
public class XMLSocketS
public static void main(String[] args) throws IOException
//Establish a connection to socket
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(4545);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(1);
Socket clientLink = null;
try
clientLink = serverSocket.accept();
System.out.println("Server accepts the client request.....");
BufferedInputStream inn = new BufferedInputStream(clientLink.getInputStream());
BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:/xampp/htdocs/received_from_client.txt")));
byte[] buff = new byte[1024];
int readMe;
while( (readMe = inn.read(buff)) >= 0)
{ //reads from input stream, writes the file to disk
ut.write(buff, 0, readMe);
ut.flush();
//Sending response to client
//============================================================
BufferedInputStream ftoC = null;
BufferedOutputStream outtoC = null;
// File to be send over the socket.
File file = new File("c:/xampp/htdocs/thesis/user_registration_response.xml");
try
// InputStream to read the file
ftoC = new BufferedInputStream(new FileInputStream(file));
}catch(IOException eee)
{System.out.println("Problem reading file");}
// OutputStream to socket
outtoC = new BufferedOutputStream(clientLink.getOutputStream());
byte[] buffer = new byte[1024];
int noRead;
//Checking if bytes available to read to the buffer.
while( (noRead = ftoC.read(buffer)) >= 0)
// Writes bytes to Output Stream from 0 to total number of bytes
outtoC.write(buffer, 0, noRead);
outtoC.flush();
//============================================================
System.out.println("File received");
}catch(IOException ex)
{System.out.println("Exception.");}
finally
try
if (clientLink != null) clientLink.close();
}catch(IOException e) {}
clientLink.close();
//serverSocket.close();
}CLIENT SIDE
import java.io.*;
import java.net.*;
public class XMLSocketC
@SuppressWarnings("deprecation")
public static void main(String[] args)
// Server: "localhost" here. And port to connect is 4545.
String host = "127.0.0.1";
int port = 4545;
BufferedInputStream fileIn = null;
BufferedOutputStream out = null;
// File to be send over the socket.
File file = new File("c:/xampp/htdocs/thesis/sensorList.xml");
try
// InputStream to read the file
fileIn = new BufferedInputStream(new FileInputStream(file));
}catch(IOException eee)
{System.out.println("Problem");}
try
System.out.println("Establishing Socket Connection");
// Opening Socket
Socket clientSocket = new Socket(host, port);
System.out.println("Socket is clear and available.....");
// OutputStream to socket
out = new BufferedOutputStream(clientSocket.getOutputStream());
byte[] buffer = new byte[1024];
int numRead;
//Checking if bytes available to read to the buffer.
while( (numRead = fileIn.read(buffer)) >= 0)
// Writes bytes to Output Stream from 0 to total number of bytes
out.write(buffer, 0, numRead);
// Flush - send file
out.flush();
//=======================================
DataInputStream in = new DataInputStream(new BufferedInputStream(clientSocket.getInputStream()));
BufferedWriter outf = new BufferedWriter(new FileWriter("c:/xampp/htdocs/received_from_server.txt",true));
String str;
while(!(str = in.readLine()).equals("EOF")) {
System.out.println("client : Read line -> <" + str + ">");
outf.write(str);//Write out a string to the file
outf.newLine();//write a new line to the file (for better format)
outf.flush();
//=======================================
// close OutputStream
out.close();
// close InputStrean
fileIn.close();
// close Socket
clientSocket.close();
}catch (IOException e)
{System.out.println("Exception.");}
Could you please point where am I doing the stupid mistake, client to server is working properly, but the opposite direction is not.
Thanks -
Hi All,
I am facing problem with license server. We have installed SAP Business One , Did License import, Installed patch 15 and than again DTW and every thing. Now when I want to connect through DTW, it gives error messege : connection to license server failed . Any help on it will be highly appriciated. Thanks,
SabitaHi Sabita,
Is it just the DTW that fails (ie can you log in to the SBO client)?
In newer versions of the DTW, the License Server setting in the log in screen needs to have both the server name (or IP address) and port number. For example:
MYSERVER:30000
where MYSERVER is the name of the server where the license service is installed and 30000 is the port number it is running under (30000 is the default).
Kind Regards,
Owen -
Hi;
I want to learn client server programming on using windows xp for the client and windows server 2003.
I downloaded the 9.2 windows xp database version for the client . What do I need to download for the server? I see that there is a 32 and 64 bit version for the server.
Thanks for your help!What I was asking is what should I install on the server
the 32 or 64 bit version of oracle?
I want to learn how to write client/server programs using Oracle.
I have a network at home with one computer serving as the client and another has server 2003 on it.
Again Thanks for your help! -
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. -
Problem with Application Server Portal 9.0.2.0.1.
I have a problem with Application Server Portal and Wireless 9.0.2.0.1.
Firstly I've installed the infrastructure on a Pentium 3 866Mhz 512Mb of Ram, with Windows 2000 Server (Italian) service pack 2.
I've maintained all predefined settings and I've chosen the UTF8 character set.
After installation, my infrastructure and OID works fine. The OID has port 4032 (as set by Oracle Universal Installer) instead of predefined 389.
After this I've installed Application Server Portal and Wireless on another host: a Pentium 3 733Mhz 384Mb of Ram, with Windows 2000 Server (Italian) service pack 2.
I've also maintained all predefined settings and automatic configuration of Portal and Wireless. I've pointed to my Infrastructure.
Try to test the Portal demonstration but an error occurred:
"SERVICE TEMPORARILY UNAVAILABLE. The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later."
On my EM Console I see: component instances 'OC4J_Portal' and 'OC4J_Demos' are UP, instead 'Portal:portal:7777' is down.
On the component lists I've clicked the link of component instance Portal:portal:7777, the 'control services' and 'Accessible Server SSO' are started, while 'Accessible Portal Repository' is down.
What can I do to get my portal started?hi,
i have exactly the same problem. did you solve yours?
any suggestions or help how to do it?
thanks
erik
please reply to this post or [email protected]
Maybe you are looking for
-
Common use of Sequence in Package
Hi, I need to get the NEXTVAL from a sequence and i have to pass that to many packages inside of a package. If i write SELECT seq.nexval into v_varil from dual; means the value wont change sequentially. How can i get the NEXTVAL sequentialy and decla
-
Hi, I have some problem to call web service generated from BAPI on WAS 6.20. My Scenario is the following: I took the famous BAPI_FLIGHT_GETLIST, generate Web Service on WAS 6.20, and consume it throw Web Dynpro Web Service model on WAS 6.40. Now, I
-
Hi, I am having trouble sending a username field to a url using post. My code is listed below: HttpConnection http = null; OutputStream oStrm = null; InputStream i = null; boolean ret = false; // Data is passed as a se
-
How to convert yyyymm -mmyyyy format
Hi All, How do I convert 0Fiscper format from yyyymm to mmyyyy in transformation rules Thanks Nau
-
Is it possible to download and read books from Waterstones in the ebook format on iPad. If so how? Is there any need to download an app? Thanks