receive the same response from the server - glued
HelloI write a simple client/server application. I'm a little stuck on the same response from the server. Instead of sending and receiving plain text, I chose to wrap messages in the command objects (containing a statement and a list of values). He worked for a while, until I realized that I continue to create new objects for each request and response to and from the server. I thought that it's a waste, so I created a reset method (commands command) to update the same object instance instead of creating new command objects. And since I get the same response from the server.
I've debugged client and the server, and I see that it is as if the server does not read a new order, but he is stuck on the last (which is the first).
It's the class ServerThread run() method:
@Override
public void run() {
try {
out = new ObjectOutputStream(socket.getOutputStream());
in = new ObjectInputStream(socket.getInputStream());
Command fromClient = null, toClient = null;
Protocol p = new Protocol();
try {
//Reading input from Client
while ((fromClient = (Command) in.readObject()) != null) {
toClient = p.processInput(fromClient);
out.writeObject(toClient);
}
} catch (EOFException e) {
//Swallow this exception
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
out.close();
in.close();
socket.close();
} catch (SocketException e) {
//Swallow this exception
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
It's the processInput (...) method of the class of Protocol:public Command processInput(Command fromClient) {
if (fromClient.getCommand() == Commands.REQ_GREET_ME) {
currentCommand.reset(Commands.REPLY);
currentCommand.addValue(new Value("Welcome to the Aardenon server."));
} else if (fromClient.getCommand() == Commands.REQ_PLAYER_COUNT) {
currentCommand.reset(Commands.REPLY);
currentCommand.addValue(new Value("There are " + AcceptorThread.threadCount() + " players online."));
} else if {
//Some other commands...
}
return currentCommand;
}
It's the method of hand (...) (shortcut) to the customer class:public static void main(String[] args) {
ClientUI clientUI = new ClientUI();
clientUI.printWelcome();
Socket socket = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
BufferedReader stdIn = null;
try {
socket = new Socket("localhost", PORT);
if (socket != null) {
clientUI.printConEstablished();
out = new ObjectOutputStream(socket.getOutputStream());
in = new ObjectInputStream(socket.getInputStream());
stdIn = new BufferedReader(new InputStreamReader(System.in));
Command currentCommand;
CommandCreator commandCreator = new CommandCreator();
Command toServer = new Command(), fromServer;
String fromUser;
try {
toServer.reset(Commands.REQ_GREET_ME);
out.writeObject(toServer);
fromServer = (Command) in.readObject();
if (fromServer != null) System.out.println(fromServer.getValue(0).get());
toServer.reset(Commands.REQ_PLAYER_COUNT);
out.writeObject(toServer);
fromServer = (Command)in.readObject();
if (fromServer != null) System.out.println(fromServer.getValue(0).get());
//Here some more conversation based on user input...
//Handle exceptions and finally...
I hope that the code is self-explanatory.PR.
Try to play with ObjectOutputStream.reset (). My understanding is that the same object to write to the stream of data twice causes some kind of optimisation whereby the second time that only a reference to the first serialized object is written. Reset() can cause the object to rewrite it completely in its new State.
PS: Creating objects is cheap these days. Don't feel that you were running a premature optimization? I'm not saying you do, just be wary of him! You can already see a negative effect of it: more fragile code and more complicate.
Tags: Java
Similar Questions
-
This does not happen with IE for the same pages. He has just begun because I installed the v4 and now it happens with beta v5.
Click on the Firefox button, go to Options | Options | Advanced and in the network tab, menu storage offline, click on the button "clean now".
-
I have a requirement to encrypt my server for transport off-site backups, so I'll try to store my backups to an external drive that is encrypted for BitLocker. I am doing a test restore to a new drive to simulate a full system recovery, but I'm unable to unlock the drive encrypted with the backup of the prompt under system recovery options.
I have confirmed that I can unlock the drive from a command inside the original Windows installation prompt using manage - bde.wsf and the recoverypassword, but the same command does not work from the command prompt during the recovery process (started from the installation DVD). There is no error code, a single message that the recovery key did not work and administrator privileges may be required.
When you try the same command from another server when connected to that drive, I got an error that can be informative, code 0 x 80310037, implying that the recovery key may not because of the FIPS compatible algorithms that are needed.
I'm looking for something that isn't possible trying to store the complete system on a BitLocker encypted disk backups? Any help would be greatly appreciated.
Thank you
Jayhttp://www.Microsoft.com/windowsserver2008/en/us/forums-blogs.aspx
Repost in the Forums 2008 Server at the address above.
They will help.
See you soon.
Mick Murphy - Microsoft partner
-
How to send a file in the server of the University Complutense of MADRID using the Code?
Hello
I tried several times to upload a file to the server of the University Complutense of Madrid from the adf page, but I can't do it.
First: I have used this method to do, but it feel that the file downloaded successfully and when I open the server I haven't found this...
public String addNewContent() {} InputStream fileStream = null; try {} createConnection(); String filePath = "C:\\Users\\Administrator\\Desktop\\ucm classes\\Class1.java"; String autherName = "weblogic"; fileStream = new FileInputStream (filePath); = New File (filePath); String [] fileTitle = filePath.split("/"); long fileLength = new File (filePath) .length (); param.getBinder (.putLocal (CMConstants.CM_SERVICE_NAME), CMConstants.CM_CHECKIN); param.getBinder () .putLocal ("dDocType", "Application"); Title of the downloaded file param.getBinder () .putLocal ("dDocTitle", fileTitle [fileTitle.length - 1]); Name of the author param.getBinder () .putLocal ("dDocAuthor", autherName); Content security for (Group and account) param.getBinder () .putLocal ("dSecurityGroup", "Public"); param.getBinder () .putLocal ("dDocAccount", ""); param.getBinder () .putLocal ("dFormat", "text/html"); param.getBinder () .putLocal ("xCollectionID", (getFolderIdFromPath ("/ Contribution dossiers/22 /"))) ; param.getBinder () .addFile ("primaryFile", file); param.setServiceResponse (param.getIdcClient (.sendRequest (param.getIdcContext ()), (param.getBinder ())); InputStream myInputStream = param.getServiceResponse () .getResponseStream (); String myResponseString = param.getServiceResponse () .getResponseAsString (); System.out.println ("downloaded file Details: \n" +) myResponseString); DataBinder myResponseDataBinder = param.getServiceResponse () .getResponseAsBinder ();
! = null) {}System.out.println ("file uploaded successfully"); } catch {(IdcClientException idcce) System.out.println ("IDC customer Exception occurred. Cannot download the file. Message: «+» idcce.getMessage () + ", the stack trace:"); idcce.printStackTrace (); } catch (IOException ioe) {} System.out.println ("IO Exception has occurred. Cannot download the file. Message: «+» ioe.getMessage () + ", the stack trace:"); ioe.printStackTrace (); } catch (Exception e) {} System.out.println ("Exception occurred. Cannot download the file. Message: «+» e.getMessage () + ", the stack trace:"); e.printStackTrace (); } {Finally If (param.getServiceResponse ()! = null) {} param.getServiceResponse (m:System.NET.Sockets.Socket.close ()); } If (fileStream try {} fileStream.close (); } catch (Exception e) {} e.printStackTrace (); } } } Returns a null value.
} ----------------------------------------------------------------------
Second: I used this method, but it did not work also
public String uploadFile() {} try {} String inputFile1 =""; UF UploadedFile = (UploadedFile) inputFile1.getValue (); String filePath="C:\\Setup\\mmm.txt; » InputStream fileStream = null; try {fileStream = new FileInputStream (filePath) ;} catch (FileNotFoundException e) {}} String [] fileTitle = filePath.split("/"); long fileLength = new File (filePath) .length (); // DataBinder Binder = IdcClient.crea param.getBinder (.putLocal (CMConstants.CM_SERVICE_NAME), CMConstants.CM_CHECKIN); param.getBinder () .putLocal ("dDocAuthor", "weblogic"); If the user is admin, can specify any user param.getBinder () .putLocal ("dDocTitle", "titleee"); param.getBinder () .putLocal ("dDocName", "nameee"); param.getBinder () .putLocal ("dDocType", "DigitalMedia"); param.getBinder () .putLocal ("xCollectionID", getFolderIdFromPath ("/ files/11 Contribution")); parent folder param.getBinder () .putLocal ("dSecurityGroup", "Public"); param.getBinder () .putLocal ("dDocAccount:", ""); param.getBinder () .putLocal ("xComments", "Review of Montreal"); param.getBinder () .putLocal ("xWCTags", "Montréal"); param.getBinder () .addFile ("primaryFile", new TransferFile (fileStream, 'child', fileLength, "text/html")); ServiceResponse response = param.getIdcClient (.sendRequest (param.getIdcContext ()), param.getBinder ()); } catch (Exception e) {} System.out.Print(""); } Returns a null value. } -------------------------------
Can someone tell me what's wrong? !
Thank you
This will definitely work
package demo; import java.io.*; import oracle.stellent.ridc.*; import oracle.stellent.ridc.model.*; import oracle.stellent.ridc.protocol.*; import oracle.stellent.ridc.protocol.intradoc.*; import oracle.stellent.ridc.common.log.*; import oracle.stellent.ridc.model.serialize.*; import oracle.stellent.ridc.protocol.http.*; import java.util.List; /* * This is a class used to test the basic functionality * of submitting a checkin to Content Server using RIDC. */ public class TestRIDCCheckin { public static void main(String[] args) { // Create a new IdcClientManager IdcClientManager manager = new IdcClientManager(); try { // Create a new IdcClient Connection using idc protocol (i.e. socket connection to Content Server) IdcClient idcClient = manager.createClient("idc://localhost:4444"); // Create new context using the 'sysadmin' user IdcContext userContext = new IdcContext("sysadmin"); // Create an HdaBinderSerializer; this is not necessary, but it allows us to serialize the request and response data binders HdaBinderSerializer serializer = new HdaBinderSerializer("UTF-8", idcClient.getDataFactory()); // Databinder for checkin request DataBinder dataBinder = idcClient.createBinder(); dataBinder.putLocal("IdcService", "CHECKIN_UNIVERSAL"); //dataBinder.putLocal("dDocName","TestRIDCCheckin"); dataBinder.putLocal("dDocTitle", "Test RIDC Checkin"); dataBinder.putLocal("dDocType", "Document"); dataBinder.putLocal("dDocAccount", ""); dataBinder.putLocal("dSecurityGroup", "Public"); dataBinder.addFile("primaryFile", new File("c:/test.txt")); //dataBinder.putLocal("doFileCopy", "1"); // Write the data binder for the request to stdout serializer.serializeBinder(System.out, dataBinder); // Send the request to Content Server ServiceResponse response = idcClient.sendRequest(userContext, dataBinder); // Get the data binder for the response from Content Server DataBinder responseData = response.getResponseAsBinder(); // Write the response data binder to stdout serializer.serializeBinder(System.out, responseData); } catch (IdcClientException ice) { ice.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } }
-
copy objects from one server to another schema
Hello.
Oracle 11g running on multiple servers.
Is it possible to copy tables and procedures, at the same time
from one server to another using sqlplus?
For example, I would like to do something like this:
From sqlplus on server1:
create or replace mytable from dblink_server2.mytspace.mytable;
Any suggestions are greatly appreciated.
Thank you.user652257 wrote:
Why does in SqlPlus but not in my procedure?You need a direct privilege to create objects to work through the procedures or plsql.
Grant Create Table to user1;
HTH
SS
-
NB200-h-13 - no response from the DNS server and gateway
Hello
I have netbook NB200-h-13 with XP SP3. Its impossible to connect to wireless internet and the error messages are
HE DIDN'T THERE WAS NO RESPONSE FROM THE DNS SERVER
HE DIDN'T THERE WAS NO RESPONSE FROM THE DEFAULT GATEWAYThe connection with the ethernet cable is ok with the adpter reltek that also adpter atheros ar9285 WiFi is activation, working properly and the modem router signal is strong.
Hi abk55,
What program you receive this error message?
Have you tried another browser, for example Firefox or Opera?I guess it has something to do with your wireless network card or WLAN parameters if the LAN cable is working properly. So you should try to update the WLAN driver on the Toshiba site.
Also, try to disable the filtering of MAC addresses and use another encryption. -
I have an application that sends emails when running. Off late a user when he tries to send a mail it receives the following error message...
"System.Net.Mail.SmtpException: unavailable mailbox." "The response from the server is: 5.7.1 error: content rejected '...
Note that this happens when he tries to send mail to itself and not otherwise. Can someone here on which could mean the error? Thanks in advance... :))
Error code is generated in the back-end.
'System.Net.Mail.
to System.Net.Mail.
to System.Net.Mail.
to System.Net.Mail.
to System.Net.ClosableStream.
to System.Net.Mail.MailWriter.
to System.Net.Mail.SmtpClient.
Hi guys,.
Thanks for the reply!
I contacted my sources by taking care of the servers and realized that the user was an id in which the address of the server was not set up with our servers in domain. He used to connect to our servers using the VPN client. This is why he could not send mails to id field not (in this case itself).
-
original title: email problem
It was something I did on 'email settings', I think, with the POP3...? Think I might have my gmail sent to my msn account... I can't understand. I can open all the files, sent mail, etc... but cannot send or receive e-mail from this account. It works on Hotmail on other computers and even this same computer. get the error code: 0x85ad3202 "no connection with the server? Thank you for any suggestions/help DJ
If you need help with MSN, experts are loitering in the forums 'on-line'.
Windows Live Solution Center
http://windowslivehelp.com/ -
read and receive data from the server
Hi all
I want to develop an application that extract data related to the content of the server, how to do? I read somewhere stating this task requires sdk server push? is it possible do not use push sdk server and the server reading so that I don't have install anyting from the server.
Your Web service code decides how much data you send or receive from the customer.
For example, you can have a Web service method, which returns records to a particular date, then you must create a web service method that accepts a date to a string as a parameter and a request for service records of server request, write resultset in encoding (like xml, json, etc) and return this string as a response to the client client will read the data as a byte array, then converts the byte array to the string and according to the encoding defined by service will analyze data of interest.
-
Cannot publish - no response from the server
Can I publish is no longer one of my Web sites. I get the message "no response from Server" for each of them. I waited a few hours, same result. I uninstalled and reinstalled Muse - still nothing.
In its current wording, all my sites are now unnecessary toally - and I have some major updates to make.
Everything was fine until that I've updated the product, now its totally redundant. This "useful" someday
What can you do to correct the killer Adobe update?
You are using IE or IE are the browser by default or not, you must do the following:
(1) in Internet Explorer go to tools > Internet Options > advanced
(2) scroll down the "settings."
(3) find the boot options "use SSL... ' and 'use TLS... ". »
Put 4) the option "Use SSL 3.0" (and any higher version number, if you have one).
(5) turn on all the options "use TLS... "(versions 1.0, 1.1, etc..)
6) click OK to the dialog box.
Now stop Muse, if it is running. Launch, open your file and publish them.
-
An error has occurred has not got a response from the software update server (update.local). What should I do to update my laptop?
It is one of the many problems that occur on my mac.
Update of OS X El Capitan 10.11.4?
1. backup Mac.
2. install 10.11.4 combo update.
https://support.Apple.com/kb/DL1869?viewlocale=en_US & local = en_US
-
Satellite Pro P100: Wlan with no response from the server proxy C-27
I have a laptop model Satellete Pro P100 and tries to connect to a wireless router.
I was able to connect to it over the past four months.Last week, I connected to a wired network and now he refuses to re - connect to my home wireless network. He acknowledges that I am connected but connectivity doctor says "there is no response from the server proxy (c-27).
A friend in the House is able to connect to the internet with their computer without problem.
I have tried everything I know, but need help please. Thank youHello
Have you checked in the properties of Wlan settings and the TCP/IP properties?
Please check if the options: IP automatically get an address and get server address DNS are automatically set correctly. -
Hello world!
First of all, I use a USRP as a transmitter to emit a sine wave (the signal is exp(j2*pi*f*t)), and then I use the external clock to synchronize the two USRPs (Ref as PPS in are connected to the clock) as receivers. Receivers are in sync, and they are at the same distance from the transmitter, I thought that the signal they receive should have a nearly the same phase. However, in practice, the phase shift is big enough, and this problem really confuses me.
It's the received signals of 2 receivers.
Yes. What you observe is expected.
Near the bottof of this document read the area 'alignment Phase vs Phase coherence '.
http://www.NI.com/white-paper/14311/en/
And also, for the alignment phase, see the following 'Angle of arrival detection with NI USRP '.
https://decibel.NI.com/content/docs/doc-25716
Erik
-
Hello
I get the below error message while my windows application inserts data in SQL Server.
A transport-level error has occurred when receiving results from the server. (provider: TCP provider, error: 0 - the semaphore timeout period has expired.)
I use LINQ-to-SQL. SQL Server is installed on Windows server 2003.
We are using SQL server 2008 r2.
When we insert large data base records, approximately 1 million we get this question.
Please suggest.
Hello
When you use Windows server, we ask you to send the query in the link depending on whether they are the experts.
http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer
Thank you.
-
My laptop was working fine yesterday, but when I started it today I get the message "Wireless association failed because Windows did not receive response from the access point or wireless router.
I can see my network and I can connect to the internet using my desktop pc, but just to make complicated I can't even connect to the network when I plug the ethernet cable into my laptop.
I think it might be a driver problem, but I have no idea how to solve this problem without access to the internet on my laptop.
I'm running Vista and my wireless router is an Atheros AR5009 809.11a/g/n
I need step by step instructions on this Yes please treat me like a fool!
Thank you
Laptop would not work at home thus concluded that it was a BT Broadband do not issue my driver (despite BT telling me the opposite last night)
After the call to a fantastic Lady in BT it's all fixed and thanks to Jack I now know a lot more on connecting wireless to my laptop!
Maybe you are looking for
-
Tecra A11 on Replicator Toshiba showing not external monitor
I tried 2 nine different laptops on 2 different nine port replicator toshiba both experience the same problem. When you connect to the laptop from the dock on the first part of windows XP loading is shown. When windows starts, the external display is
-
Shows box irritating when I go on a website. I re - configure IE, re-installed Firefox, got rid of the Google toolbar, check the extensions and got rid of some, all I can think about. Read the article on the problem, followed instructions, etc, all t
-
I constantly get messages that say that I do not use the latest version of Firefox and then do not display properly. I use v3.6.3 and get this message on many sites I visit. Just noticed that in the assumptions below - even if it thinks I'm using the
-
Launch of the App store Mac OS 10.11.2 produces an empty window with corkscrew that persists without filling the screens of spinning. I pref deleted files, cache files, restart the Mac, waited for hours without improvement. If anyone can help, that w
-
Item selection listbox with right click of the mouse
Hello I have a ListBox with unchangeable elements. Y at - it an easy way to select an item with a click of the right button (like the left click)