Reading from http server

Hi guys and girls,
I've got a simple problem: i'm busy programming a browser (for now it's a simple text based browser) and everything works fine, the connection works and it gets all http headers and the html file. But once and a while my program doesn't terminate properly and i think it's got something to do with the following loop:
/* Read the first line returned by the server */
String fromServer = input.readLine();
while (fromServer != null){
System.out.print(fromServer+"\r\n");
/* Read the next line untill that line is blank*/
fromServer = input.readLine();
Sometimes this works, sometimes it doesnt (mind you: the http headers are received before this loop, so that's not the problem). This loop should get the html file at the specified url: at some locations it just keeps running and it doesn't exit, so this loop isn't exited because right after it i close my connections and perform a System.exit().
Does anyone have any idea what my problem is? The loop should stop when the server doesn't send anymore lines from the html file: it shows the html closing tag everytime so that is the last line from the html file, yet it fails to exit the loop. The weird thing is: sometimes it works properly, sometimes it doesn't., and when it doesn't it doesn't show input anymore so all html text is sent by the server.
Are there other ways to make the program exit the loop when all the lines from the html file are sent?
The input stream i use is a buffered inputstream reader:
input = new BufferedReader(new InputStreamReader(c.getInputStream()));
Hope you understand the problem :)

1. You didn't show what kind of connection u get. For example HttpConnection may be looped due
to response redirection.
2. I think the best practice for the case is to read bytes from the stream but not lines, for instance:
int c = 0;
while( (c=in.read())>=0 ){
.... do something
}

Similar Messages

  • Reading from application server

    Hi All,
    I have a requirement wherein I need to uplaod an excel sheet which contains Material number, Plant and PO text. And accordingly update the material and plant with the given PO text. Now, if i have mat1, Plant1 and PO text given for this combination in the excl as below:
    "This is the new PO Text
    Please Update it"
    If the above is the PO text (with a line's gap between 2 statements), the requirement is to upload this text into application server. Then in the update program, i need to read this text for the corresponding material and plant.
    The uploading is happening correctly into the app server:
    Mat1     Plant1     This is the new PO Text 
                               Please Update it
    But while reading from the application server in the update program, the first read dataset statement reads only Mat1     Plant1     This is the new PO Text. This record is filled in the internal table meant for update. The structure of the internal table is Material, Plant, PO text.
    Now the control goes to the next read dataset statement and reads text "Please Update it". This text is filled in the material column of the internal table and hence gives an error at the time of update.
    The syntax used to upload into app server is :
    OPEN DATASET p_path FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
    Transfer each record
    The syntax used to read from app server is :
      OPEN DATASET p_path FOR OUTPUT IN TEXT MODE ENCODING DEFAULTIf sy-subrc = 0.
    Do.
    Read dataset p_path into v_appltxt (where v_appltxt is of type string)
    if sy-subrc = 0.
         fill the internal table for update.
    Else.
    exit.
    Endif.
    Enddo.
    Please help me rectify the issue at the time of reading from the app server so that the PO text(no matter how is in entered in the excel sheet) is read against the correspoding material and plant combination.
    Thanks

    Hi Jean,
         READ DATASET statement will always read one line of input file at a time. Since the PO text is not continuous, Its gettng read into material number in the next fetch.
         As a solution, try to keep the PO text entirely while uploading data to application server. You may have to put in logic to remove extra lines after the data is retrieved from the excel sheet to the internal table.
    Hope this helps.
    ~Athreya

  • About the read from http request, I think it is a bug in weblogic

    Hi guys,
    sorry for the previous post, I press the wrong button, I didn't finished yet.
    I have experienced a problem when I try to read from http request in a web application.
    the following is my code:
    InputStreamReader isr = new InputStreamReader(new URL("www.myhost.com").openStream(),"8859_1");
    BufferedReader bfr = new BufferedReader(isr);
    String request = "";
    while((request = bfr.readLine()) != null)
    stringGotFromServer += request;
    the problem is it always hang in there when BufferdReader reach the end.
    but in java specification, BufferedReader should reture null if reaching the
    end.
    Does anyone have any good idea for that?
    Thanks in advance.

    Hi,
    I think if you follow the instructions as given in the example you will not have any problems.
    here are the instructions below
    "This example code demonstrates one technique of handling test failures.
    If this step fails, a dialog will be displayed giving options to Break, Terminate, or Retry.
    The On Fail Post Action calls the HandleTestFailure sequence which is
    another sequence in this sequence file.
    The sequence file has the SequenceFilePreStep Callback overridden where
    the initial statue of Runstate.SequenceFailed is stored in a local variable. Create a local variable in your sequence called SequenceAlreadyFailed which is a boolen.
    To use this in your sequence file:
    1. Copy the HandleTestFailure sequence to your sequence file.
    2. For a step to use this, you
    must set the On Fail Post Action to call the
    HandleTestFailure sequence.
    3. Override the PreStepCallback.
    4. Copy the step from this example's PreStepCallback to yours.
    5. Copy the TestFailureDialog.* files to the same directory as your sequence file.

  • Can any body help me in reading from HTTPS URL

    I need to read an HTTPS URL and store the response within a table .
    How will I manage to do it from within a servlet using URLConnection and openStream as it does'nt work .
    How will JSSE help in this regard .
    Since I also need to give the userid and password to get into the file and read the file
    https://anyhost.com/readthisfile.html
    somnath
    Web Developer

    Hi,
    The Java Secure Socket Extension (JSSE) library from Sun Microsystems lets you access a secure Web server from behind a firewall via
    proxy tunneling. To do this, the JSSE application needs to set the https.ProxyHost and https.ProxyPort system properties. The
    tunneling code in JSSE checks for "HTTP 1.0" in the proxy's response. If your proxy, like many, returns "HTTP 1.1", you will get an
    IOException. In this case, you need to implement your own HTTPS tunneling protocol.
    In this article, I will show you how to create a secure socket that tunnels through the firewall, and pass it to the HTTPS stream handler to
    open HTTPS URLs using the URLConnection class.
    Open the http tunnel socket to the proxy
    The first step to creating your secure socket is to open the tunneling socket to the proxy port. The code needed to do this proxy
    handshaking can be found in the sample code SSLClientSocketWithTunneling.java that comes with the JSSE distribution. First, a normal socket is created that connects to
    the proxy port on the proxy host (line 65). After the socket is created, it is passed to the doTunnelHandshake() method where the proxy's tunneling protocol is called:
    54 SSLSocketFactory factory =
    55 (SSLSocketFactory)SSLSocketFactory.getDefault();
    56
    57 /*
    58 * Set up a socket to do tunneling through the proxy.
    59 * Start it off as a regular socket, then layer SSL
    60 * over the top of it.
    61 */
    62 tunnelHost = System.getProperty("https.proxyHost");
    63 tunnelPort = Integer.getInteger("https.proxyPort").intValue();
    64
    65 Socket tunnel = new Socket(tunnelHost, tunnelPort);
    66 doTunnelHandshake(tunnel, host, port);
    In doTunnelHandshake(), an http "CONNECT" command is sent to the proxy, with the secure site's hostname and port number as the parameters (line 161). In the original
    tunneling code on line 206 in JSSE, it then checks for "HTTP/1.0 200" in the proxy's reply. If your organization's proxy replies with "HTTP 1.1", an IOException will be
    thrown. To get around this, the code here checks for the reply "200 Connection Established", which indicates that tunneling is successful (line 207). You can modify the
    code to check for the expected corresponding response from your proxy:
    139 private void doTunnelHandshake(Socket tunnel, String host, int port)
    140 throws IOException
    141 {
    142 OutputStream out = tunnel.getOutputStream();
    143 String msg = "CONNECT " + host + ":" + port + " HTTP/1.0\n"
    144 + "User-Agent: "
    145 + sun.net.www.protocol.http.HttpURLConnection.userAgent
    146 + "\r\n\r\n";
    147 byte b[];
    148 try {
    149 /*
    150 * We really do want ASCII7 -- the http protocol doesn't change
    151 * with locale.
    152 */
    153 b = msg.getBytes("ASCII7");
    154 } catch (UnsupportedEncodingException ignored) {
    155 /*
    156 * If ASCII7 isn't there, something serious is wrong, but
    157 * Paranoia Is Good (tm)
    158 */
    159 b = msg.getBytes();
    160 }
    161 out.write(b);
    162 out.flush();
    163
    164 /*
    165 * We need to store the reply so we can create a detailed
    166 * error message to the user.
    167 */
    168 byte reply[] = new byte[200];
    169 int replyLen = 0;
    170 int newlinesSeen = 0;
    171 boolean headerDone = false; /* Done on first newline */
    172
    173 InputStream in = tunnel.getInputStream();
    174 boolean error = false;
    175
    176 while (newlinesSeen < 2) {
    177 int i = in.read();
    178 if (i < 0) {
    179 throw new IOException("Unexpected EOF from proxy");
    180 }
    181 if (i == '\n') {
    182 headerDone = true;
    183 ++newlinesSeen;
    184 } else if (i != '\r') {
    185 newlinesSeen = 0;
    186 if (!headerDone && replyLen < reply.length) {
    187 reply[replyLen++] = (byte) i;
    188 }
    189 }
    190 }
    191
    192 /*
    193 * Converting the byte array to a string is slightly wasteful
    194 * in the case where the connection was successful, but it's
    195 * insignificant compared to the network overhead.
    196 */
    197 String replyStr;
    198 try {
    199 replyStr = new String(reply, 0, replyLen, "ASCII7");
    200 } catch (UnsupportedEncodingException ignored) {
    201 replyStr = new String(reply, 0, replyLen);
    202 }
    203
    204 /* We check for Connection Established because our proxy returns
    205 * HTTP/1.1 instead of 1.0 */
    206 //if (!replyStr.startsWith("HTTP/1.0 200")) {
    207 if(replyStr.toLowerCase().indexOf(
    208 "200 connection established") == -1){
    209 throw new IOException("Unable to tunnel through "
    210 + tunnelHost + ":" + tunnelPort
    211 + ". Proxy returns \"" + replyStr + "\"");
    212 }
    213
    214 /* tunneling Handshake was successful! */
    215 }
    Overlay http tunnel socket with SSL socket
    After you have successfully created the tunneling socket, you overlay it with the SSL socket. Again, this is not difficult to do:
    54 SSLSocketFactory factory =
    55 (SSLSocketFactory)SSLSocketFactory.getDefault();
    56
    57 /*
    58 * Set up a socket to do tunneling through the proxy.
    59 * Start it off as a regular socket, then layer SSL
    60 * over the top of it.
    61 */
    62 tunnelHost = System.getProperty("https.proxyHost");
    63 tunnelPort = Integer.getInteger("https.proxyPort").intValue();
    64
    65 Socket tunnel = new Socket(tunnelHost, tunnelPort);
    66 doTunnelHandshake(tunnel, host, port);
    67
    68 /*
    69 * Ok, let's overlay the tunnel socket with SSL.
    70 */
    71 SSLSocket socket =
    72 (SSLSocket)factory.createSocket(tunnel, host, port, true);
    73
    74 /*
    75 * register a callback for handshaking completion event
    76 */
    77 socket.addHandshakeCompletedListener(
    78 new HandshakeCompletedListener() {
    79 public void handshakeCompleted(
    80 HandshakeCompletedEvent event) {
    81 System.out.println("Handshake finished!");
    82 System.out.println(
    83 "\t CipherSuite:" + event.getCipherSuite());
    84 System.out.println(
    85 "\t SessionId " + event.getSession());
    86 System.out.println(
    87 "\t PeerHost " + event.getSession().getPeerHost());
    88 }
    89 }
    90 );
    The code had called the SSLSocketFactory's getDefault() method earlier to get an instance of the SSLSocketFactory (line 54, repeated above). Next, it passes the
    tunneling socket that was created in the previous step to the createSocket() method of the SSLSocketFactory. The createSocket() method returns an SSLSocket that is
    connected to the destination host and port via the proxy tunnel. You can optionally add a HandshakeCompletedListener to the socket if you wish to be informed when the
    SSL handshaking is completed.
    The SSLSocket created is basically ready for use to transfer secure contents. The startHandshake() method is called to start the SSL handshaking (line 98). After which, you
    can issue the http "GET" command to retrieve the secure pages (line 105):
    91
    92 /*
    93 * send http request
    94 *
    95 * See SSLSocketClient.java for more information about why
    96 * there is a forced handshake here when using PrintWriters.
    97 */
    98 socket.startHandshake();
    99
    100 PrintWriter out = new PrintWriter(
    101 new BufferedWriter(
    102 new OutputStreamWriter(
    103 socket.getOutputStream())));
    104
    105 out.println("GET http://www.verisign.com/index.html HTTP/1.0");
    106 out.println();
    107 out.flush();
    However, issuing http commands to the tunneling SSL socket to access Webpages is not ideal because it would mean having to rewrite the whole http protocol handler from
    scratch. Instead, you should use the HTTPS URL APIs that the JSSE already includes for that purpose. To do this, you have to pass the tunneling SSL socket to the HTTPS URL
    stream handler.
    Pass SSL socket to HTTPS URL stream handler
    The JSSE library has an HttpsURLConnection class that is in the com.sun.net.ssl package, which extends the java.net.URLConnection class. An HttpsURLConnection object
    is returned by the URL object's openConnection() method when "HTTPS" is specified as the protocol. The HttpsURLConnection class has a method, setSSLSocketFactory(),
    that lets you set an SSLSocketFactory of your choice. To pass the tunneling SSL socket to the HTTPS URL stream handler, you would set the setSSLSocketFactory()
    method's parameter with a socket factory that returns the tunneling SSL socket that you created previously.
    To do this, you would wrap the code discussed previously in an SSLTunnelSocketFactory class that extends from the SSLSocketFactory class. The SSLSocketFactory is an
    abstract class. To extend it, you must implement the createSocket() method to return the tunneling SSL socket that you created earlier:
    12 public SSLTunnelSocketFactory(String proxyhost, String proxyport){
    13 tunnelHost = proxyhost;
    14 tunnelPort = Integer.parseInt(proxyport);
    15 dfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
    16 }
    44 public Socket createSocket(Socket s, String host, int port,
    45 boolean autoClose)
    46 throws IOException,UnknownHostException
    47 {
    48
    49 Socket tunnel = new Socket(tunnelHost,tunnelPort);
    50
    51 doTunnelHandshake(tunnel,host,port);
    52
    53 SSLSocket result = (SSLSocket)dfactory.createSocket(
    54 tunnel,host,port,autoClose);
    55
    56 result.addHandshakeCompletedListener(
    57 new HandshakeCompletedListener() {
    58 public void handshakeCompleted(HandshakeCompletedEvent event) {
    59 System.out.println("Handshake finished!");
    60 System.out.println(
    61 "\t CipherSuite:" + event.getCipherSuite());
    62 System.out.println(
    63 "\t SessionId " + event.getSession());
    64 System.out.println(
    65 "\t PeerHost " + event.getSession().getPeerHost());
    66 }
    67 }
    68 );
    69
    70 result.startHandshake();
    71
    72 return result;
    73 }
    Notice that the SSLTunnelSocketFactory contains a default SSLSocketFactory object. The default SSLSocketFactory object can be instantiated from a call to the static
    method getDefault() (line 15). You need this SSLSocketFactory object to overlay the tunnel socket with the SSL socket, as discussed earlier. You also call the default
    object's getDefaultCipherSuites() and getSupportedCipherSuites() methods when implementing the corresponding abstract methods of the SSLSocketFactory super
    class. For implementation details, please refer to the complete source code for the SSLTunnelSocketFactory in Resources.
    Tunnel through the proxy via URLConnection
    To tunnel through the proxy via URLConnection in your JSSE application, after you call the openConnection() method, check if the returned object is that of the
    HttpsURLConnection. If so, you instantiate your SSLTunnelSocketFactory object and set it in the setSSLSocketFactory() method (lines 22 through 25):
    10 public class URLTunnelReader {
    11 private final static String proxyHost = "proxy.sg.ibm.com";
    12 private final static String proxyPort = "80";
    13
    14 public static void main(String[] args) throws Exception {
    15 System.setProperty("java.protocol.handler.pkgs",
    16 "com.sun.net.ssl.internal.www.protocol");
    17 //System.setProperty("https.proxyHost",proxyHost);
    18 //System.setProperty("https.proxyPort",proxyPort);
    19
    20 URL verisign = new URL("https://www.verisign.com");
    21 URLConnection urlc = verisign.openConnection(); //from secure site
    22 if(urlc instanceof com.sun.net.ssl.HttpsURLConnection){
    23 ((com.sun.net.ssl.HttpsURLConnection)urlc).setSSLSocketFactory
    24 (new SSLTunnelSocketFactory(proxyHost,proxyPort));
    25 }
    26
    27 BufferedReader in = new BufferedReader(
    28 new InputStreamReader(
    29 urlc.getInputStream()));
    30
    31 String inputLine;
    32
    33 while ((inputLine = in.readLine()) != null)
    34 System.out.println(inputLine);
    35
    36 in.close();
    37 }
    38 }
    You can then access the HTTPS URLs using the APIs provided by the URLConnection class. You don't need to worry about the format of the http GET and POST commands,
    which you would if you used the SSL Socket APIs.
    The complete source code for the SSLTunnelSocketFactory and the application code that connects to a secure URL using proxy tunneling is included in Resources. To
    compile and run the application, you would need to download and install Sun's JSSE from its Website, also listed in Resources.
    Conclusion
    If your JSSE application could not tunnel through your organization's firewall, you need to implement your own tunneling socket. The sample code included with the JSSE
    distribution shows you how to open an SSL socket tunnel. This article goes one step further to show you how to pass the tunneling socket to the HTTPS URL stream handler,
    and saves you the trouble of rewriting a http handler
    I hope this will help you.
    Thanks
    Bakrudeen

  • Post XML from HTTPs server

    How do I get the HTTPs server to send/post the XML file to user's mailbox?
    The situation is like this: User from System A need to send XML file to User in System B. These 2 can't communicate directly.So the XML file will be posted to an HTTPs server. This HTTPs server will then post the XML to the recipient based on the mailboxid. This mailboxid is specified in the XML. How do i send the XML to the designated mailbox?

    You write something that runs on the server, receives
    the uploaded XML file, attaches it to an e-mail
    message, and sends that message. Since you ask in the
    Java context, that something could be a servlet. (You
    will notice that this applies equally well to files
    that aren't XML.)Hi there! Thanks for the feedback. So I need to create a servlet in the HTTPs server which upon receiving of the XML file, servlet need to read the XML content to get the mailboxid then attach the XML file to that mailboxid? All these can be done in one servlet? Please correct me id I'm wrong. Your feedback is highly appreciated. Thanks..:)

  • Apex SSL from  HTTP server - err 29040

    Have apex environment (originally 3.1.2 now 3.2) workiing fine under http server 10.1.3. regular http port 7777.
    After going thru the ssl and wallet documentation steps to apply certificates supplied to me, and scouring all the blogs, I'm still failing under https 4443 with:
    SSL call to NZ function nzos_Handshake failed with error 29040
    The default oracle ewallet.p12 lets me in after first complaining about the certificates. I made a new wallet, with owm, and added in the trusted certs that are suppsoed to match our internal browsers. Thats when things go wrong.
    I've tried, and of course bounced opmnctl with stopall, startall after changing each one:
    (1) in opmn.xml verified <ssl enabled="true"
    (2) auto-logon checked in the wallet with cwallet.sso,
    (3) left it off, regen'd wallet and set SSLWalletPassword to it's value,
    (4) tried and verified different wallet locations and the right settings in ssl.conf. (feel confident the ssl.conf settings work cause I can cause other errors by commenting out SSLWalletPassword in ssl.conf with auto-logon=off),
    (5) SSLVerifyClient set to none
    (6) in opmn.xml verified <data id="start-mode" value="ssl-enabled"/>
    (7) set LogLevel in httpd.conf to Debug (more output but nothing obviously usefull)
    (8) set SSLLogLevel in ssl.conf to debug (more output but nothing obviously usefull)
    any ideas would be much appreciated. AND especially does anyone know what the default password is for that default ewallet.p12 ?
    if it told me during install I must have missed it. first born for that cause maybe I can modify it and add in my certs ?

    Srini, thanks so much for helping. Sorry I didn't reply right off hand. To be honest I couldn't find doc id 473047 in metalink and then I finally got hold of our Certificate group and have been busy with them and just now got things resolved. Thanks again for replying. Really appreciate it.
    If anyone else stumbles across this in the future, after having installed just the http server and not knowing much about it, the default pwd to the default wallet is welcome. (be sure and make a copy of this ewallet.p12 in conf/ssl.wlt/default before playing with it). The invalid cipher clues of the 29040 msg were not the direct problem in my case. For me it ended up being incomplete wallet information as the root cause under 10.1.3.
    At first we had been just inserting trusted certificates into the wallet thinking that should match our inhouse browser images. Instead the "Warning, this is a development" msg kept showing. Finally we went thru the steps outlined in the documentation, using owm xwindows (or orapki) to create a new wallet from scratch, add a user certificate request, save the wallet, then export the user cert req to a flat file. You can then send that to your internal security group (assuming you have one) or whoever your Cert Authority is. They then send you back a new certificate that should constitute your User Certificate. You must first load in your trusted certificates (usually a Root and Issuing type trusted certs to constitute your "chain"). Then you can do a Import User Cert under owm and load in the afiorementioned fiel recvd from you security group. Also note the ON= value on your request must equal your DNS name as in server.xyz.com Also, I was being sent .key files that I could never import in. They then sent me pem files that had the key info blended in from what I understand and those worked.
    I was able to get variations of the 29040 error (290xx) by trying different values within the HTTPD.conf -> ssl.conf file for the various SSL variables. In the end I've ended up with the modified settings of
    SSLCipherSuite ALL
    SSLProxyCipherSuite ALL
    SSLVerifyClient none
    SSLProtocol ALL
    SSLProxyProtocol ALL
    although I suspect other combinations would be fine as well.
    The opmn/conf settings were set to the various values as seen in other postings and blogs but in the end did nto seem to be the issue for me. Other than modifying those <port local="6xxx" remote="6xxx" request="6xxx"/> to prevent the opmn logs from filling up fast. To do that I had to try different values that the ones found in some of the main google postings.

  • Change APEX from HTTP-Server to 11g

    Hello together
    I installed an Oracle 10gR2 Database and Apex 3.1 is running on the HTTP-Server (from the 10gR2 Companion CD).
    Now i want to upgrade to 11g and use the embedded PL/SQL Gateway so that i can turn off the HTTP-Server. Have you got any tips to do that ? Is there something specially ?
    Thanks for your help.

    Andrew, there is a number of posts on this forum with exactly the same issue and resolutions to the issue. Please search the forum. If you do not find a solution, let me know and I'll help you from there.
    Ludek

  • Invalid WSDL - Certificate not trusted - Exception while publishing WSDL in OSR from HTTPS Server

    Hi,
    I am publishing a Web Service in OSR from an HTTPS Server. I am getting exception as
    Error message:
    WSDLException: faultCode=INVALID_WSDL: java.io.IOException: java.security.cert.CertificateException: Server certificate ....... is not trusted!
    To remove this exception I have done following steps
    a) Added Certificate from remote server in Identity Store of WebLogic Server using keytool utilitity
    keytool -import -alias devCertificate -file c:/certificates/okdsoa.cer -truststore demoIdentityStore.jks
    b) Added Certificate from remote server in the trust store of weblogic server using keytool utility
    keytool -import -alias devCertificate -file c:/certificates/okdsoa.cer -truststore demoTrust.jks
    This didnot help.
    Then I imported certificate to OSR using PStoreTool command as
    PStoreTool.bat add -config C:/OSRHome/registry111/conf/clientconf.xml -certFile c:/certificates/okdsoa.cer
    Bounced the servers but that also didnot help.
    Can you please suggest?
    Thanks,
    Parshant

    I found the fix from Oracle Support Knowlededge Base
    sslTool serverInfo --url https://HOST:9043 --certFile newcert.cer
    PStoreTool located in REGISTRY_HOME/bin/PStoreTool add -config
    WEBLOGIC_HOME/user_projects/domains/[osr_domain_name]/servers/[osr_server_name]/tmp/_WL_user/registry/[unique id]/public/conf/pstore.xml -certFile newcert.cer
    I was updating wrong file with the certificate. It had to be pstore.xml. This solved my issue.
    Thanks & Regards,
    Parshant

  • Reading from a server

    I'm supposed to read the following C struct from a server
    struct query_type{
    int flag;
    int query_a;
    int query_b;
    char next pass[30];
    typedef struct query_type t_query;
    I tried
    Socket s = new Socket( serverName, serverPort );
    DataInputStream dis = new DataInputStream( s.getInputStream() );
    String message = dis.readUTF(); //wait for server to send
    s.close() // close the socket
    as the basic idea for my first connection but i didn't receive anything i think.
    what i want to do is try and receive the whole transmission and then separate it.
    here's the class i've created to match the struct:
    public class queryType
    protected int flag;
    protected int query_a, query_b;
    protected String nextPass;
    public queryType()
    flag = 0;
    query_a = 0;
    query_b = 0;
    public int getFlag()
    return flag;
    public int getQueryA()
    return query_a;
    public int getQueryB()
    return query_b;
    public String getNextPass()
    return nextPass;
    someone said i should use a byte array, but i'm not exactly sure what he meant.
    I think that i know how many bytes C uses to store int values and char values, but i'm not sure how this would help me.
    Really I need help figuring out what reader to use so that i can manipulate the data received.
    any ideas???

    you may try reading this way... That was probably what they meant when talking about byte array...
    Socket sock = new Socket(ip_addr, port);
    BufferedInputStream in = new BufferedInputStream(sock.getInputStream());
    bbufin = new byte[BUF_LEN];
    int err = 0;
    err = in.read(bbufin, 0, BUF_LEN);

  • Unreliable reading from AFP server (NAS)

    Following on from some earlier problems, I've started encountering a new, and much worse, problem. After I successfully connect to the AFP share, I can look at the contents of various remote folders in Finder. But, some of the folders are just showing as empty, even though I know they aren't. I tried waiting several minutes, nothing showing up (and there doesn't seem to be any way to tell if Finder is waiting for a response or not - with other folders you may get the same result, but the files usually show up after a few seconds).
    There doesn't seem to be any particular pattern to it. Certain folders show all their contents, others just appear to be empty. Also, if I try to list the contents of these folders from the command line (ls -la /Volumes/Share/Folder) then once again it works for the same ones that work in Finder, but it otherwise it just hangs. I am getting similar problems sometimes trying to unmount certain shares from the command line with diskutil: again, it just hangs.
    This wasn't happening when I tried it recently (as suggested in the thread referenced at the top of this post) and the only thing to have changed about my system since then is this update:
    http://support.apple.com/kb/HT6207
    I'm not sure if that's likely to have anything to do with it, or if it's just because I've not been using the NAS from the Mac so much lately (mostly been working on Windows stuff the last couple of weeks). Maybe it's just coincidence that this is the first time I've noticed it.
    I've tried restarting the Mac and the NAS and the same thing is happening even from that completely clean state (so no chance anything has gone into sleep mode or similar). I can access the same folders with no problems from a Windows PC over SMB. For some reason when I try to connect to the SMB share from Mavericks it completely fails to read the contents of any shared volume, so I have to use AFP (or possibly figure out what's wrong with SMB, but that could be a much harder problem to solve).
    I couldn't find much about this issue by googling, although I did find a recommendation to clear the Finder cache. However, on my system, ~/Library/Caches/com.apple.finder doesn't exist. Has this been removed from Mavericks?
    There's always a chance this could be a problem with the AFP implementation on the NAS, whch is an Asustor AS-202T, running the latest software (ADM 2.1.1.R3B2). Is anyone else on here using an Asustor NAS?

    hi,
    any luck resolving this?
    I am investigating the slow large directory reading problem between macbook OS X Mavericks 10.9.5 and NAS Asustor 202TE ADM 2.2.1.R863
    Basically, reading a large directory (c. 2,000 files) is very slow.
    Then, deleting a file is fast the first time, then any subsequent delete, in same session, seems to cause a file list refresh, and slow again.
    This is very painful to review sets of files created daily from my garden cam, where most need to be deleted.
    I really don't want to boot up a windows machine for this task.
    Potential solutions / areas to investigate:
    1. mac tcp parameters: delayed_ack, packet size, frames etc
         found a good resource here for this, but I haven't found any combination that makes a difference for me
    2. turning off icon previews etc
         done this, no change
    3. directory list cache: client side vs server side
         cannot find any info relating to the Asustor or mac implementation
    4. finder replacement
         not sure this has any benefit
    5. smb vs afp
         I haven't noticed any performance difference, so doubt this is significant
    Any help would be appreciated.

  • XML file not properly read from Appc Server. Partial records filled into IT

    Hi,
    I am reading an XML file from the application Server. only 2 records are comming to the Internal table. Other records are not coming to the Internal Table. It's giving Sy-Subrc 4 after 2 iterations. Below is my code. Kindly suggest.
    open dataset p_unix in text mode message msg.
        if sy-subrc <> 0.
          message i001(38) with 'Error on Open of File: ' msg.
        else.
          while sy-subrc = 0.
            read dataset p_unix into infile.
            check sy-subrc = 0.
            append infile.
          endwhile.
          close dataset p_unix.
    Thanks,
    Debi.

    Hi,
    this is probably because there's only one "end of line" character (probably after <?xml ... ?>). This is normal, but you must store the second line in a string data object, which will then receive the whole XML stream (except the xml header as it is stored in the first line). And that's done.
    BR
    Sandra

  • Read from datasocket server

    The question is simple. Is there any way to know the variables and values that have been written to the datasocket server without creating a VI that reads values?
    Thanks for your help

    I'm afraid that it is not possible. You must read the items from the DataSocket Server to know the item values that are been publishing
    crisR

  • HTML Body is lost from when it is read from Exchange Server 2007 to siebel 7.7.2.12

    Hi
    An HTML Email body sent through any email client. If the body type is HTML, when it comes through POP3 Exchange server 2007 and Siebel driver reads the mail it looses the Body formatting. I have already tried with the following options
    1) Adminstration Communication -> Communication Drivers and Profiles -> Internet SMTP/POP3 Server -> Driver Parameters -> Create Plain Text From HTML to True - This did not help
    2) Adminstration Communication -> Communication Drivers and Profiles -> Internet SMTP/POP3 Server -> Driver Parameters -> Convert Incoming To Plain Text to True - This did not help
    Both the combination did not help
    We also tried changing the POP3 properties at Exchange server level, where any email that is coming will always gets changed to plain text or HTML even that did not help.
    Any suggestions or recommendations are highly appreciated.
    Thanks
    Bhanu

    Hi,
    I also think it's caused due to the software confliction, to verify this, please perform a clean boot:
    Log on to the computer by using an account that has administrator rights.
    Click Start, type msconfig.exe in the Start Search box, and then press Enter to start the System Configuration utility.
    Note If you are prompted for an administrator password or for confirmation, you should type the password or provide confirmation.
    Collapse this imageExpand this image
    On the General tab, click the Selective startup
    option, and then click to clear the Load startup items check box.  (The
    Use Original Boot.ini check box is unavailable.)
    Collapse this imageExpand this image
    On the Services tab, click to select the Hide all Microsoft services check box, and then click
    Disable all.
    Collapse this imageExpand this image
    Note This step lets Microsoft services continue to run. These services include Networking, Plug and Play, Event Logging, Error Reporting, and other services. If you disable these services, you may permanently delete all restore points. Do not
    do this if you want to use the System Restore utility together with existing restore points.
    Click OK, and then click Restart.
    If there's no issue in clean boot, I suggest you double check the settings or the better way to contact the developer of the softwares to do further research on this issue.
    Thanks,
    Melon Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Changed setting to no proxy but not solved problem Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /iam/services/setContext. Reason: Error reading from remote server

    This problem only happens with one website when I try to follow hyperlinks to other pages. They have directed me to Firefox troubleshooting section. I have followed the advice there but it has not solved my problem.

    I haven't been able to go on line since 7.01 and up. I have to use ieexplorer. are you idiots or what. I can't even contact you because i have to be in your latest version but i can't get the internet with the latest version. good bye for good

  • Reading binary content from HTTP?

    As long as i read text (ascii) data from a HttpURLConnection, the resulting stream (written to a file) is okay (readable). but when i want to read a PDF file with the same code, the written output file is not readable with the Acrobat reader (file type not supported or file corrupted):
                    //read data from HTTP server:
                    InputStream is = null;
                    HttpURLConnection con = null;
                    try {
                        System.out.print(key+": connecting ...");
                        con = (HttpURLConnection) url.openConnection();
                        if (con instanceof HttpsURLConnection) { //HTTPS URL?
                            //avoid "java.io.IOException: HTTPS hostname wrong:  should be <217.5.135.142>"
                            ((HttpsURLConnection) con).setHostnameVerifier(new HostnameVerifier() {
                                public boolean verify(String hostname, SSLSession session) {
                                    return true;
                        System.out.print(" reading ...");
                        try {
                            is = con.getInputStream();
                            try { //in case input stream is compressed via GZIP:
                                is = new GZIPInputStream(is);
                            } catch (IOException ioe) {
                                //ignore (input stream is not GZIP compressed)
                        } catch (IOException ioe) {
                            System.err.println("Error getting input stream. HTTP return code: "+con.getResponseCode()+" ("+con.getResponseMessage()+"). "+ ioe);
                            return;
                        IOUtils.writeStream(is, os);
                    } catch (Exception e) {
                        System.err.println("\nError getting content from URL: " + e);
                        return;
                    } finally {
                        if (is != null) { try { is.close(); } catch (IOException ioe) { ioe.printStackTrace(System.err); } }
                        if (con != null) { try { con.disconnect(); } catch (Exception e) { e.printStackTrace(System.err); } }
                        if (os != null) { try { os.close(); } catch (IOException ioe) { ioe.printStackTrace(System.err); } }
                    }when i open the written pdf file with a text editor, i noticed the the first line is
    DF-1.4
    so, the first character "P" is missing. but even when i add the "P" in the text file and save it, Acrobat Reader shows the same error.
    is there another way to load binary data from a HttpUrlConnection and/or write it to a file?

    yes, it's simple and works with text/ascii content from URLS:
         public static void writeStream(InputStream inputStream, OutputStream outputStream) throws IOException {
            if (inputStream != null && outputStream != null) {
                int count;
                byte[] bytes = new byte[128];
                while ((count = inputStream.read(bytes, 0, bytes.length)) != -1) { //use full read() method for GZIPInputStream to be treated correctly
                    outputStream.write(bytes, 0, count);     
        }//writeStream()it's pdf content that doesn't work (completely). the first two characters "%P" are mssing. if i add them by hand (e.g. my writting this two characters to the outputSTream before continuing with the PDF content), the resulting file is okay (can be read by acrobat reader).
    perhaps, some inner Java class misinterpret the "%P" characters as a special code sequence?

Maybe you are looking for