Change url connection to socket
hello i have a problem about a socket connection can you help me
i want to change url connection to socket connection
here is
java.net.URL url = new java.net.URL("http://64.74.75.74/approot/webapp/ZOR/bare");
connection = new sun.net.www.protocol.http.HttpURLConnection(url, " ", 0);
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(connection.getOutputStream());
out.writeObject(getTextFieldGiden().getText());
out.flush();
out.close();
return (String) (new java.io.ObjectInputStream(connection.getInputStream()).readObject());how can i change it to
socket connection because i must write it in c++
thank you very much
why are you replaying if you don' t have a solution peter?
i have a big c++ project and in it somewhere must do the job the code i send in java do.
İ also want to say i dont want it's c++ code ,i want to know how it can be with java sockets.
Similar Messages
-
Proper way to change URL connections
When viewing a page of search results from Google with the search term "java", I get the following URL: http://www.google.com/search?hl=en&q=java&btnG=Google+Search
Page 2 is associated with the URL: http://www.google.com/search?q=java&hl=en&lr=&safe=off&start=10&sa=N
In order to change pages programmatically, do I need to do anything with the first URLConnection before creating a second URLConnection?All google needs is q and start, so your first page would be:
http://www.google.co.uk/search?q=test&start=0
second:
http://www.google.co.uk/search?q=test&start=10
http://www.google.co.uk/search?q=test&start=1000
Or you could use the Google Web API. -
I have created a bundle for the class com.xxx.cq.wcm.foundation.profile.impl.TnailImages from the foundation file com.day.cq.wcm.foundation.profile.impl.ProfileImages.
Here are the changes I made ot this class
1. width and height for the default foundation class ProfileImages to have our own default width and height in TnailImages.
2. selectors changed to our own like
* @scr.property name="sling.servlet.selectors" values.0="adjust"
* values.1="adjust.small"
3. Variable changed to private static final String THUMBNAIL = "small";
4. Metatype annotation won't compile for CQ5.5 I changed this * @scr.component metatype="false"
to
* @Component(immediate = true)
This bundle compiled successfully and I see it in OSGi felix console, it is in start mode. Even then I did a restart of this bundle as well as whole CQ5.
When I call an image using the following tag
<img alt="" src="/content/dam/geometrixx/portraits/scott_reynolds.jpg.adjust.small.jpg">
there are no spases anywhere
the servlet ThumbNailImages is not being call, I see the following error in error.log
servletengine Unable to send back last chunk: Software caused connection abort: socket write error
this image is not being displayed in the page, firebug displays failed to load URL
Default img works fine
<img alt="" src="/content/dam/geometrixx/portraits/scott_reynolds.jpg.prof.thumbnail.jpg">
Class com.day.cq.wcm.foundation.profile.impl.ProfileImages is available in
/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/profile/impl/ProfileImag es.java
Here are my annotations * @Component(immediate = true) * @scr.service * @scr.property name="sling.servlet.resourceTypes" value="nt:file" * @scr.property name="sling.servlet.extensions" values.0="res" * values.1="jpg" * values.2="png" * values.3="gif" * @scr.property name="sling.servlet.selectors" values.0="adjust" * values.1="adjust.small" */ It seems that this servlet is not being called, when I invoke http://xyz.com:4502/content/dam/geometrixx/portraits/scott_reynolds.jpg.adjust.small.jpg I am getting 404 Cannot serve request to /content/dam/geometrixx/portraits/scott_reynolds.jpg.adjust.small.jpg in org.apache.sling.servlets.get.DefaultGetServlet
3 (2013-05-20 11:02:40) TIMER_END{2,resolveServlet(JcrNodeResource, type=dam:Asset, superType=null, path=/content/dam/geometrixx/portraits/scott_reynolds.jpg)} Using servlet com.day.cq.dam.core.impl.servlet.BinaryProviderServlet 3 (2013-05-20 11:02:40) TIMER_END{2,ServletResolution} URI=/content/dam/geometrixx/portraits/scott_reynolds.jpg.adjust.small.jpg handled by Servlet=com.day.cq.dam.core.impl.servlet.BinaryProviderServlet
It seems that my Servlet TnailImages is not being called, it is always going to default servlet.Hi Akhter,
Seeme like in your servlet the value for resourceType set to nt:file. Change it to "sling/servlet/default" and verify.
Thanks,
Sham -
hello all,
I hope you can help me.
Please have a look at my code below
I open an URL Connection but I can't close it.
If i type in a DOS Box netstat I see a lot of connection.
Now my question is how can I close the connection.
m_http.disconnect() seems not to work.
public class Unbenannt1 extends Applet
Button button1 = new Button();
private HttpURLConnection m_http = null;
private URL m_MyAlarmURL = null;
private URLConnection m_MyURLConnection = null;
private long m_TimeAlarmXML = 0;
private boolean m_TimeUpdate = true;
/**Das Applet initialisieren*/
public void init()
String a_str = "http://"+ getCodeBase().getHost() + "/x.xml";
try
m_MyAlarmURL = new URL( a_str );
catch ( MalformedURLException ie )
try
jbInit();
catch(Exception e)
e.printStackTrace();
/**Initialisierung der Komponenten*/
private void jbInit() throws Exception
button1.setLabel("button1");
button1.setBounds(new Rectangle(27, 28, 78, 27));
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
setLayout(null);
setBackground(java.awt.Color.lightGray);
setSize(426,266);
this.add(button1, null);
void button1_actionPerformed(ActionEvent e)
int a_int = 0;
try
m_MyURLConnection = m_MyAlarmURL.openConnection();
m_http = (HttpURLConnection)m_MyURLConnection;
m_http.setRequestMethod( "HEAD" );
m_http.setUseCaches(false);
m_http.connect();
a_int = m_http.getResponseCode();
m_http.disconnect();
m_http = null;
m_MyURLConnection = null;
System.gc();
catch ( java.io.IOException ioe )
a_int = 404;
}Thanks a lot
PredigerUsually those connections linger around for some time, and will then be closed by the OS once a certain timeout has been reached. I don't know how to change that timeout, though.
Btw: the docs don't claim that the connection will be closed. The description for disconnect() is "Indicates that other requests to the server are unlikely in the near future"
If you still see the connection after a while, then something is wrong, but I've seen connections like that hang around for several minutes even after the JVM was terminated.
Thomas -
Fetching a URL from a socket output or input stream in a proxy server
We have written a proxy server in java .
It connects with a client on some local port and forwards the request of the client to main server through socket connections.
The code is as follows...
* BasicProxyServer.java
* A simple multithreaded proxy server.
* A client connects to theserver. The server starts a
* separate threads for data flow though two Sockets.
* The first socket communicates with the socket of the client.
* The second socket is used to communcate with the main server
* for which this server is a proxy. The sockets are connected by pipes.
import java.net.*;
import java.io.*;
public class BasicProxyServer {
private static int serverPort;
private static String primaryServerHost;
private static int primaryServerPort;
// 1st arg: port to listen on
// 2nd arg: primary server IP
// 3rd arg: primary server port
public static void main(String [] args) {
serverPort = Integer.parseInt(args[0]);
primaryServerHost = args[1];
primaryServerPort = Integer.parseInt(args[2]);
BasicServer bserv = new BasicServer(serverPort,primaryServerHost,primaryServerPort);
class BasicServer extends Thread {
private int serverPort;
private String primaryHost;
private int primaryPort;
private ServerSocket servSock = null;
public BasicServer(int port, String primSrv, int primPort) {
serverPort = port;
primaryHost = primSrv;
primaryPort = primPort;
start();
public void run() {
Socket clientSock = null;
Socket primaryServerSock = null;
try {
servSock = new ServerSocket(serverPort);
catch (IOException e) {
e.printStackTrace();
while(true) {
try {
clientSock = servSock.accept();
primaryServerSock = new Socket(primaryHost, primaryPort);
PipedInputStream fromClient = new PipedInputStream();
PipedOutputStream toMainServer = new PipedOutputStream(fromClient);
PipedInputStream fromMainServer = new PipedInputStream();
PipedOutputStream toClient = new PipedOutputStream(fromMainServer);
Talk clientToMainServer = new Talk(clientSock, fromClient, primaryServerSock, toMainServer);
Talk mainServerToClient = new Talk(primaryServerSock, fromMainServer, clientSock, toClient);
clientToMainServer.start();
mainServerToClient.start();
catch (IOException e) {
e.printStackTrace();
// Override finalize() to close server socket
protected void finalize() {
if (servSock != null) {
try {
servSock.close();
} catch (IOException e) {
e.printStackTrace();
servSock = null;
class Talk extends Thread {
private Socket incoming;
private Socket outgoing;
private InputStream in;
private OutputStream out;
private InputStream from;
private OutputStream to;
Talk(Socket inSock, InputStream in, Socket outSock, OutputStream out) {
this.in = in;
this.out = out;
incoming = inSock;
outgoing = outSock;
public void run() {
int aByte;
try {
from = incoming.getInputStream();
to = outgoing.getOutputStream();
while(( aByte = from.read()) != -1 ) { //read from socket
out.write(aByte); // write to pipe`
// read the byte from the pipe
to.write(in.read()); // write it to the output socket stream
to.flush();
to.close();
from.close();
if(incoming != null) {
incoming.close();
incoming = null;
if(outgoing != null) {
outgoing.close();
outgoing = null;
catch (SocketException e) {
// there is one for a closed socket. Seems to have no effect.
// e.printStackTrace();
catch (IOException e) {
e.printStackTrace();
Here,when client gives any URL in the address bar in the web browser the request is forwarded to this proxy server.
We want to fetch the URL which client enters in order to implement content filtering and also store the most visited sites by each user .
But we don't know how to fetch the URL from the socket input or output stream.
Can you suggest any suitable solution for the same??Shailesh24 wrote:
We want to fetch the URL which client enters in order to implement content filtering and also store the most visited sites by each user .
But we don't know how to fetch the URL from the socket input or output stream.
Can you suggest any suitable solution for the same??Yes. Write a proxy server that actually speaks HTTP. -
Changing database connection in bpel process
Hi i have a problem and three different choices.
Problem:
i have an application made in oracle forms that calls an oracle bpel process and interacts with the database.
the problem is that i have 3 differents databases with differents users to impact that form.
i have already working that process in 1 database.
I have three choices and only two are worthy.
First choice:
create 2 new process for each database from zero. (setting different string connections to the databases,so the form will call differents url depending on what database is in).
second choice:
create 2 new process by copying the first one and changing the process name and the string connection and the url connection (but dunno how to do this).
third choice:
Switch inside the process somehow between the 3 different string connections to different databases.
The first one is not actually an option because the flow of the process is really large and have a huge amount of variables.
If someone could help me i would really apreciate it. THANKS!what I understood is that your forms may call any of the 3 databases. give a try to Dynamic PartnerLink http://www.oracle.com/technology/pub/articles/bpel_cookbook/carey.html. You will have one parent process that will be called by the forms. Now this bpel process based on the parameters sent by form, will call any of the three bpel process pointing to three different databases.
Please explain in further details if my understanding is wrong. -
Jdeveloper 9.0.3.1 problems to change DB connection
Inside the BC4JModule, at the configuration manager, it has the possibility to define the connection type. One JDBC URL and the other JDBC Datasource.
At the first time I had defined my BC4J to use the JDBC URL connection an it worked. At the second deployment I chose the JDBC Datasource and had problems.
To continue the development I decided to define my BC4J module again with the JDBC URL connection but with the JDeveloper 9.0.3.1 it is not more possible to change and "SAVE" the configuration again. It remains always to JDBC datasource connection.
I started than the "OLD" 9.0.3 JDeveloper and it works. What is wrong?You should post this question to the Jdeveloper discussion forum for an appropriate answer: JDeveloper and ADF
Regards,
OTN -
Hello,
I do get the below SQL error in production environment intermittently:
TCP connection closed but a child process of SQL Server may be holding a duplicate of the connection's socket. Consider enabling the TcpAbortiveClose SQL Server registry setting and restarting SQL Server. If the problem persists, contact Technical
Support.
According to the post I search in MSDN, the above error is fixed in SQL2008R-CU6, but I have SQL2008R2-SP02 CU09 patch in production environment and the above error still occurred intermittently. I am running SQL2008R2 SP02 CU09 patch with Windows 2008R2-SP01.
I would like to know if anyone has the same error happened to their SQL environment after applied SQL2008R2-SP02 CU06 patch and later.
Any suggestion would be helpful.
Best regards,
PL.Hello,
What happen if you apply the changes on the registry explained on the workaround section of the following article?
http://support.microsoft.com/kb/2491214
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
Hi experts
I have created a BSP application , In login pafe i want to change URL which we use for TEST .
Or can can i redirect to another url , when TEST the page.
Thanks & Regards
Prashant GuptaHi Prashant,
Re-directing to another URL on load of page is a very simple piece of HTML code.Put this on the layout of page from where you want to re-direct to the other URL.
<html>
<head>
<metas http-equiv="refresh" content="0;url=http://sdn.sap.com">
</head>
</html>
Here the important line is the 3rd line which begins with "<metas". The operation is "refresh" which means to "refresh" the current page with the information that follows. The content begins with a zero, which is the number of seconds to wait, and then the URL that you should be taken to.
So the above code would re-direct you to the http://sdn.sap.com page as soon as you log in.
Hope this helps!
PS : meta changed to metas to allow adding of the code.
Regards,
Saurabh -
Right Way to change MBOs Connections
Hellow Experts,
I'm really enjoying the communication here, and I got a new one.
Whats the right way of change MBOs Connections to SAP for instance?
I tried 2 methods.
Method One
Title: Its just too much Work
Proceeding:
I start rebinding every MBO and operatios to the new Connection.
Drawback:
If i have 1 MBO it may takes 30 seconds if they are 40 or 50 mbos it will take a lot of time.
there are the output tables from bapis are recreated if dont they are deleted.
so you have to reimplement all the operations one again. and it as the adicional
problem that we all can miss something and do something wrong.
Method Two
Title: Simpler way
Proceeding:
change the connection profile itself at workspace from DEV->QA or QA->PRD
Drawback:
supposing that you want independence between the apps connections like app1 is on DEV and ap 2 is on PRD.
this will led to N connections per N applications.
DEV: (Development)
QA: (Quality)
PRD: (Production)
I would like to know if you guys have more approaches and what you think of this ones.
Cheers,
LaguertaDaniel Laguerta
I will never follow method one as suggested by you.
To add for the "Method 2", i will create a separate (new) workspace for different instance like DEV, QA, PROD.
eg. Once DEV is done, i ll export the whole project, and import the same in a new workspace for QA.
Create a new SUP QA and SAP connection profile
Change connection profile to each mbo and its operations.
And deploy to SUP QA Env
Still it is time consuming.
there is another method (should be preferable)
Deploying mbo package from SCC instead of creating workspace and connection profiles.
Deploying MBO from Sybase Control Center (SCC)
Regards,
JK -
Failed to open the connection after changing the connection in CMC
Hi
Below are our environment details:
BOXI 3.1 SP3
Solaris Sparc 10
Crystal Reports 2008 Sp3
Weblogic 11g
Our team is facing the problem as described below:
We have created Crystal Reports using JDBC connection and it works fine
in an environment(SIT).
When we migrate these reports to the another environment(UAT) we get
the error "Failed to open the connection"
After migrating we indeed change the connection to Custom Database
Login Information in CMC.
So to troubleshoot we installed Crystal Reports in UAT environment and
had to perform Set DataLocation after which
the reports starting working fine.
Now when we are migrating reports to Production we have the same issue.
We cannot install Crystal Reports on Production this time and hence we
are stuck.
Please let us know if any known workaround or solution for the same.
Thanks
Kamal
Edited by: Kamalaksha Shetty on Nov 15, 2011 4:18 AMHi Meenal,
I am not 100% sure I understood the workaround of having Crystal Designer on the server. Can you connect from UAT designer to production and perform the same operation?
Check this KBA that describes this problem and a solution:
https://service.sap.com/sap/support/notes/1445067
Regards,
Julian -
What is the purpose of open/close connection data socket?
Hello everyone,
I am writing and reading values in OPC Server through data socket. What is the purpose of open/close connection data socket when writing /reading a value? Without the open/close connection element, it still work correctly. I am writing values in the server thru event stucture.I do not need any buffered reading or writing. What will happen if I didnt not use the open/close connection? Maybe it may cause some problems in my program which i didnt realise?
And I have attached an example of my program. Thanks
Yehchia
Attachments:
Test Event.vi 11 KBHi YehChia,
I was talking about something like that:
1. Not good. since with every iteration the DS connection needs to be opened and closed.
2. Good. Since you open the connection only once then do the reads and close it afterwords.
Christian -
How to find the User who changed the connection settings
Hi Gurus,
I am basically a BW guy but i am looking at your precious Guidance in this issue.
We have a situation in our BW production system. The job loads are working fine till now but seems like someone has meddled with RFC connection with R/3 prod.
The connection between R/3 and BW is broken. I would like to know if there is any way to find the User or some Log to find who might have medelled with the RFC's .
Help is greatly appreciated.
Regards
satish MHello Satish,
Which release are you on?
Option 1: Take a look in SM59 selecting the destination and there is a "last changed" information displayed.
Option 2: the table for these connections are often not logged for table change logging, but if they are... then try transaction SCU3 on the backend tables (table RFCDES is a good start).
(search for rec/client and recclient etc as search terms).
Option 3: Why would someone change a connection? Try to analyze what happened during the time period after the change, or even immediately before the change (audit logs, system events, server statistics etc). A simple check would be via SM20 to see who started SM59 immediately prior to this. A more complex check would be analyzing the RFC profiles in ST03N.
Option 4: On the R/3 side, you might be able to find the same auditable information as well (perhaps even the IP address of the caller?) Tip: The person might have created a dump... => transaction ST22.
Option 5: There are some other additional logging, tracing and control possibilities at a deeper technical level, if used or active at that point in time.
Cheers,
Julius -
Can't change the connection string of SSIS package with derived columns?
We upgraded SQL server 2008 to 2012, copied and converted all SSIS packages from Visual Studio 2008 to 2010. When I opened a package in VS 2010 and tried to change the connection string, in the local connection managers, if the data source is another
SSIS package B(.dtsx file) with derived columns, I can't change the connection string of package B. When I opened the file connection manager editor for package B and tried to locate a dtsx file in another location, saved the change, reopened the project.
Package B still pointed to previous file. Other packages without derived columns work fine. Any thoughts?We are using the package deployment model and refer to other packages in the same project. If
we changed the path of package B (with derived columns) to "D:\Visual Studio 2010\xxxx", and refer it in package A, in the A's connection manager, the connection string of package B is still its previous location "D:\Visual
Studio 2008\xxxx". When we ran the package A in the SQL server agent, the data source is still
"D:\Visual
Studio 2008\xxxx", so how can I change it to "D:\Visual
Studio 2010\xxxx"? Why has the package C (without derived columns) no such problem? thanks. -
Map Viewer URL Connection Issue
Hi,
I have an UI project, for which i have created a Deployment Profile named 'adfXXXXXUI' nothing but created a adflibrary for that UI project.
While creating the adf jar, i have come across an Option called 'Connections' .
Here i have selected Connection Names Only ... means i will be getting all the names of the connections i have created & those will be reflected in my local connection.xml file.
After configuring the rest of the params, i deployed my UI project to "deploy -> adfXXXXXUI.jar".
And we have used this jar to integrate with another UI application ... And the taskflows avilable in the jar will be used in the other UI application.
Now here is my problem ... Actually my connections.xml file has a URL Connection. This is how it looks like....
<?xml version = '1.0' encoding = 'UTF-8'?>
<References xmlns="http://xmlns.oracle.com/adf/jndi">
<Reference name="MapServer" className="oracle.adf.model.connection.url.HttpURLConnection" xmlns="">
<Factory className="oracle.adf.model.connection.url.URLConnectionFactory"/>
<RefAddresses>
<XmlRefAddr addrType="MapServer">
<Contents>
<urlconnection name="MapServer" url="http://sbsys1.intra.schneider.com:8109/mapviewer"/>
</Contents>
</XmlRefAddr>
</RefAddresses>
</Reference><Reference name="snibuilddb" className="oracle.jdeveloper.db.adapter.DatabaseProvider" credentialStoreKey="snibuilddb" xmlns="">
<Factory className="oracle.jdeveloper.db.adapter.DatabaseProviderFactory"/>
<RefAddresses>
<StringRefAddr addrType="subtype">
<Contents>oraJDBC</Contents>
</StringRefAddr>
<StringRefAddr addrType="user">
<Contents>sni_guest</Contents>
</StringRefAddr>
<StringRefAddr addrType="port">
<Contents>3720</Contents>
</StringRefAddr>
<StringRefAddr addrType="hostname">
<Contents>uxsys186v</Contents>
</StringRefAddr>
<SecureRefAddr addrType="password"/>
<StringRefAddr addrType="serviceName">
<Contents>snit0.world</Contents>
</StringRefAddr>
<StringRefAddr addrType="DeployPassword">
<Contents>true</Contents>
</StringRefAddr>
<StringRefAddr addrType="oraDriverType">
<Contents>thin</Contents>
</StringRefAddr>
</RefAddresses>
</Reference>
</References>
All the taskflows avaialble in my jar using the URL connection which mentioned above. But the adflibray jar got created with a file named 'jar-connection.xml', where i can see <Reference/> as an empty Tag. Because i have selected connections name only as an option when creating the adflibrary for my UI.
Hence it is appearing so ... But when i added this jar to the other application, i have dragged & dropped the taskflows as a region on to the JSPX page. And i started running the page. On the page .... i can see only the data which is not making use of MapServer connection defiition. Along with that, some maps needs to rendered .. but that is not happening. Rest of the page with the filter critieria is being displayed properly.
Now i have selected Include Connection Details as an option, by editing the adfLibrary Deployment profile of the UI & redeployed & found the same thing. Like, though i specify the Include Connection Details as an option ... i did not see those URL connection details in my jar-connection.xml file.Still it is not working.
All the taskflows inside the jar are trying to use this URL connection from jar-connection.xml, which is avaiable inside the adfLibUI.jar.
I tried with a scenorio some thing like ... For the application to which i have added this adfUILibrary, there itself i created a URLConnection ... but it did not worked as well.
Requesting you to let me know how can i get avail of my URL connection in to my jar ...
Thanks & Regards,
Kiran KonjetiThis is purely ssl issue. You can try adding the below logic first.. This code basically sets ssl properties for us.
import java.security.Security;
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties properties = System.getProperties();
String handlers = System.getProperty("java.protocol.handler.pkgs");
if (handlers == null) {
// nothing specified yet (expected case)
properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
else {
// something already there, put ourselves out front
properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol|".concat(handlers));
System.setProperties(properties);
Below you start your code....
Maybe you are looking for
-
When I purchase songs from the itunes storethey will show up in my itunes library but in the actual location file folder some songs are not showing up there. How do I fix this
-
How can I install two versions of the same software w/o overwriting?
Specifically, I want to install compiz-git without overwriting my current version. I'd like to just run a different command to run the git version. pkgname=compiz-core-git pkgver=20090508 pkgrel=1 pkgdesc="Composite manager for Aiglx and Xgl" url="ht
-
HT4168 Pages export to ePub - unwanted question marks
When I export a Pages doc to ePub, a question mark appears at the end of every line. How can I avoid that? If I take the Export to ePub doc from Apple and export it, no problem. If I add some lines of my own at the end and then re-export, question ma
-
4.2 Theme 25 issue/help
Hi all I am try to create multiple form on same page , I aligned all the region using grid alignment properties (create my own insert 's) everything works like a charm on desktop and smartphone but not on IPAD Region seem like cluttering into each ot
-
Where on my system is Firefox Bookmarks and Scrapbook Items?
My Macbook Air (10.6.0) has gone haywire as I can't find the Desktop or Finder and just have mostly a blue screen. The only thing I can access is the Menu at the top of the screen and I've been using File Sharing in System Preferences to move importa