Two Socket errors: Socket write and Socket reset

does anyone know the reasons and remedies for the error
java.net.SocketException: Software caused connection abort: socket write error
and
java.net.SocketException: Connection reset by peer: socket write error
please reply if someone knows
thanks

These are basically the same error triggered in different places.
This occurs when the other end of the connection closes while the client is still writing to it.

Similar Messages

  • Transaction dswp "Socket Error 10049 {Thd 5516} [socket #22A0BC, 0.0.0.0:19

    Hi,
    I just install SM 7.0 SR3 on HP-UX/Oracle 10.2. The installation finished ok.
    I have done all configuration steps with satellite systems(ECC .0 Development, ECC 6.0 Test, EC 6.0 Productive), users, RFCs,... all of this steps finished ok. SO, I have created a Solution with the three satellite systems
    I'm able to log on SAP Solution Manager system, also I've chequed java stack, both are working.
    The problem is when I go to dswp transaction, operations->solution monitoring->System monitoring/administration, the systems doesn't appears, I have a message:
    Socket Error
    Socket Error 10049 {Thd 3476} [socket #44078, 0.0.0.0:2347 to :0]
    Please could yo help me???
    Thanks and regards
    Raul

    At tr. sm21, for today only appears a error: Run-time error "GETWA_NOT_ASSIGNED" occurred at 9:21. And If I reproduce the error, It doesn't generate other run-time error like this. So, I don't think that run-time error ocurred at 9:21 was related with my problem.
    About SMICM - Goto --> Tracefile --> Display:
    [Thr 15] Tue May  6 17:24:18 2008
    [Thr 15] *** WARNING => IcmNetCheck: NiServToNo(8080) took 2 seconds [icxxman_mt.c 4594]
    [Thr 15] *** WARNING => IcmNetCheck: 1 possible network problems detected - please check the network/DNS settings [icxxman_mt.c
    [Thr  1] Tue May  6 17:25:33 2008
    [Thr  1] HttpSAPR3SetParam: switch j2ee http port from  to: 50000
    [Thr  1] HttpSAPR3SetParam: switch j2ee https port from  to: 50001
    [Thr  1] Tue May  6 17:26:51 2008
    [Thr  1] HttpSAPR3SetParam: Switched j2ee status to: 1
    The log lines refers to "May 6", so nine days ago. And It doesn't reflect any error.
    Also, in the transaction sm04, selecting the entry for the user, menu user-> trace->activate...I reproduce the error...and after return to sm04 menu user->trace->display, appears:
    Step of user SOLMANADM , seession 1 , step 9
    D  *** ERROR => invalid AREA_PIXEL data: window height = 0 [diaginp.c    1782]
    Step of user SOLMANADM , seession 1 , step 10
    Step of user SOLMANADM , seession 1 , step 11
    Step of user SOLMANADM , seession 1 , step 12
    Step of user SOLMANADM , seession 1 , step 13
    D    texts >RFC Connection Error<>F<><
    D    texts >Display Errors Only<>D<><
    D    texts >Display Errors Only<>D<><
    User trace of the next session for user SOLMANADM , Session 1 , step 1
    User trace of the next session for user SOLMANADM , Session 1 , step 1
    Step of user SOLMANADM , seession 1 , step 2
    But It doesn't indicate any idea about the error
    Raul

  • Two iphones one apple id and master reset

    Here is my issue. I just got an iphone 4s for my hubby and did a master reset on his phone. I lost all the data after that. I also use my own apple id on his cell. Will that affect syncing data, music etc. on either phone?I am trying to fugure out the best way to have the phone working properly. So, on that note, should I have one apple id or two?
    Thanks a bunch!

    that's right, sync it with your library but also make sure that your sister does not do it again as it will keep changing.
    You may wanna disable contacts sync with the iCloud on her device by taking her device and go on settings, iCloud & switch off contacts.

  • Socket Error on Recieve

    Hi Experts.
    when i try to export repository schema (or) Export Change file from the console, it is displaying "Socket Error on Recieve" and i am unable to perform any kind of operation.
    I have repaired, refreshed, stoped and started repository and server, but i didn't get any progress on this.
    Is any additional settings or operations need to perform at repository or MDM server level...?
    Can any one help me what would be the reason for this problem...?
    If this is a network issue, then what kind of things need to consider to resolve it..?
    Thanks
    Bharat

    HI Bharat,
    This is more to do with MDM server to Data base connectivity.
    I think restarting the server can solve your problem,if it does not then check if the same problem exists for other repositories also.Also,check the MDS log file entry.
    Thanks,
    Ravi

  • How to handle write errors in non blocking sockets

    Hi,
    I'm using sockets registered with a Selector for read operations. I've seen code examples that put the SocketChannel in non blocking mode before registering it with the selector, and in fact not doing so would cause an IllegalBlockingModeException to be thrown.
    My problem is that I can't handle write errors. The call to write() returns inmediately without throwing any exception. Even worse, when the network timeout expires the selector wakes up and I get an exception on read(). So I can't tell the difference between a real read error and a write error.
    What can I do? Is there a magic method I haven't heard about?
    Thanks

    ejp wrote:
    OK, so what happens is this: you write from your ByteBuffer; if there is room in the socket send buffer, the data is transferred and the transfer count is returned. (If there isn''t, the write returns zero and nothing has happened.) Your application code then continues. Meanwhile TCP is trying to send the data in the send buffer and get an ACK from the peer. If the peer is down as per your test, eventually those write attempts will time out. You will then get a connection reset exception on the next read or write.
    Even worse, when the network timeout expires the selector wakes upCorrect, to tell you there is an error condition pending. This is good, not bad.You're right. This way my program can know that something happened.
    But I still don't understand what the difference between a failed write() and a failed read() is. I mean, the error condition may appear during a send attempt, or it may appear after sending. In both cases I get an error when trying to read. How can my program know if data have been received by the other end?
    Do I have to implement ACK messages in the application level protocol??? It'd be nice if TCP could do this for me...

  • Broken Pipe Error-unable to write to socket for second attempt

    Hello,
    I am opening socket connection wuth C-server program.
    I am able to write and read from socket for first time but when tried to write second time in the same sequence gives broken pipe error.
    As seen in the code initialize() methods works perfectly fine,
    Pipe broken error is encountered for processRequest() method for writeBytes(begnmsg+"\n") method.
    Please suggest solution asap.
    Following is the code
    import java.io.*;
    import java.net.*;
    public class PowerModelClient {
         Socket kkSocket = null;
    BufferedReader in = null;
         PrintWriter out = null;
         DataOutputStream os = null;
              char m_eomChar = '\n';
    public PowerModelClient(){
    try{
    //Opens socket connection with C-server program,
    openConnection();
    System.out.println("connected to server");
    //Sends data base information to C-server program and receives acknowledgement from it.
    String recv = initialize();
    System.out.println("Initialize successful"+recv);
         try{
    // Sleep for a short period of time
         Thread.sleep ( 10000 );
    catch (InterruptedException ie) {}
         System.out.println("Initialize successfu 22l");
    //Sends data base information to C-server program and receives acknowledgement from it.
    processRequest();
    //Closes socket connection
         closeConnection();
         System.out.println("Comesout to do QUIT ");
    catch(Exception e){
         System.out.println("Error in main::"+e.toString());
         public static void main(String[] args) throws IOException {
                             new PowerModelClient();
    Opens socket connection with C-server program,
    public void openConnection() throws IOException{
    try {
                        kkSocket = new Socket("server",port);               os = new DataOutputStream(kkSocket.getOutputStream());
         //out = new PrintWriter(kkSocket.getOutputStream(),true);
    in = new BufferedReader(((java.io.Reader)(new InputStreamReader(kkSocket.getInputStream()))));
         } catch (UnknownHostException e) {
              System.err.println("Don't know about host: server.");
                        System.exit(1);
                   } catch (IOException e) {
                        System.out.println("Couldn't get I/O for the connection to: server."+e.getMessage());
                        System.exit(1);
         Sends data base information to C-server program and receives acknowledgement from it.
         This makes the C program to connect with Database.
         The data send to socket should be tagged between @BEGMSG@\nand @ENDMSG@\n
         Similary data obtained from socket will be tagged between @BEGMSG@\n and @ENDMSG@\n
    public String initialize() throws IOException{
                   int ibyteread = 0;
              String fromServer = "";
              String beginmsg=padString("@BEGMSG@");
              String endmsg = padString("@ENDMSG@");
              String recv = "";
              if (kkSocket != null ) {
    try {
                        // Set the socket timeout for ten seconds
                   //     kkSocket.setSoTimeout(10000);
                                       //String data = padString("INIT\tabcd\tisderssddsdg\tdrtrs1\twetewte");                              os.writeBytes(beginmsg+m_eomChar);
                   in.read();
              os.flush();
              os.writeBytes(data+m_eomChar);
              in.read();
         os.flush();
         os.writeBytes(endmsg+m_eomChar);
         os.flush();
         recv = readResponse(in);
    } catch (UnknownHostException e) {
    System.err.println("Trying to connect to unknown host: " + e);
                                                 // Exception thrown when network timeout occurs
                             catch (InterruptedIOException iioe)
                             System.err.println ("Remote host timed out during read operation");
                             catch (IOException e) {
                             System.err.println("IOException: " + e);
                             catch (Exception e) {
                   System.err.println("Exception: " + e);
              return recv;
    Sends data after database connection is established to socket for entitlement processing
    and will receive acknowledgement from server.
    public void processRequest() throws IOException{
                   int ibyteread = 0;
                   String beginmsg=padString("@BEGMSG@");
                   String endmsg = padString("@ENDMSG@");
                   String fromServer = "";
              if (kkSocket != null ) {
                   System.out.println("processRequest");
    try {
                             kkSocket.setSendBufferSize(1024);
                             kkSocket.setSoTimeout (10000);
                                       kkSocket.setTcpNoDelay(true);
         os.writeBytes(beginmsg+m_eomChar);
         int i = in.read();
         System.out.println("Data read is :"+i);
         os.writeBytes(padString("PAEL\t1056209\t269732\t02/01/2003")+m_eomChar);
    in.read();
    System.out.println("Data read is :"+i);
    out.flush();
    System.out.println("Data read is :"+ibyteread);
    os.writeBytes(endmsg+m_eomChar);
    ibyteread = in.read();
    readResponse(in);
    System.out.println("-----end Processing:--------");
    } catch (UnknownHostException e) {
    System.err.println("Trying to connect to unknown host: " + e);
    // Exception thrown when network timeout occurs
    catch (InterruptedIOException iioe)
    System.err.println ("Remote host timed out during read operation");
    catch (Exception e) {
    System.err.println("Exception: " + e);
    The socket requires data to be of length 1024 character, so the renaining length is padded with empty string"\0"
    public String padString(String value){
              StringBuffer strBuff = new StringBuffer(value);
                   while(strBuff.toString().length() != 1023){
                   strBuff.append("\0");
              //System.out.println("the length is "+ strBuff.toString().length());
              return strBuff.toString();
    Close socket
    public void closeConnection() throws IOException{
         in.close();
         os.close();
         kkSocket.close();
    public String readResponse(BufferedReader in) {
    boolean flag = false;
              java.lang.StringBuffer stringbuffer = new      StringBuffer(1024);
    try {
    // for(char ac[] = new char[1]; in.read(ac, 0, 1) != -1;) {
    char ac[] = new char[1024];
    if (in.read(ac, 0, 1) != -1) {
    stringbuffer.append(ac[0]);
    for(; in.read(ac, 0, 1) != -1 && ac[0] != m_eomChar; stringbuffer.append(ac[0]));
    if(ac[0] == m_eomChar) {
    System.out.println("received '" + stringbuffer.toString() + "'");
    } else {
    System.out.println("Message received by client was not properly terminated and was ignored."+stringbuffer.toString());
    } else {
    System.out.println("WARN: no response?");
    } catch(java.io.IOException ioexception) {
    System.out.println("Error in client " + ioexception + "Killing client.");
              return stringbuffer.toString();

    if I were you I would put the lines
    kkSocket.setSendBufferSize(1024);
    kkSocket.setSoTimeout (10000);
    kkSocket.setTcpNoDelay(true);
    before connecting to the server, not after the initial message was sent.

  • Imap performance and socket errors

    -bash-3.00$ imsimta version
    Sun Java(tm) System Messaging Server 6.2-8.04 (built Feb 28 2007)
    libimta.so 6.2-8.04 (built 19:28:07, Feb 28 2007)
    SunOS vmpm1 5.10 Generic_141414-02 sun4u sparc SUNW,Sun-Fire-V490
    We're experiencing imap problems that appear to be load related, and have had to restart mail services several times to restore service. The imap logs show a large number of socket errors. The server load average is in the 1-2 range; there's no apparent memory resource problem. We're seeing 600-1000 simultaneous imap sessions, which is a higher number than in the past. We run JMS & Communications Express on dedicated V490 SPARC server with 8GB of memory. We're planning to add an additional 8GB this Friday.
    Our imap configuration settings are as follows:
    -bash-3.00$ configutil | grep service.imap
    service.imap.enable = 1
    service.imap.enablesslport = yes
    service.imap.idletimeout = 30
    service.imap.maxsessions = 4000
    service.imap.maxthreads = 250
    service.imap.numprocesses = 1
    service.imap.objectclass = top
    service.imap.plaintextmincipher = 0
    service.imap.port = 143
    service.imap.sslcachesize = 0
    service.imap.sslport = 993
    service.imap.sslusessl = yes
    Can you suggest additional troubleshooting steps? Do you recommend any configuration changes?
    Thanks.

    dpelinka wrote:
    Questions:
    1. Our JMS version info doesn't state whether it is 32 or 64-bit. Therefore, I assume we are running a 32-bit version. Is that correct?Correct. There is no 64-bit version of MS6.2.
    2. Is there a virtual memory limit on the 32-bit version of JMS 6.2? Is the limit greater for JMS 6.3?The Solaris OS imposes the virtual memory size limit of ~3.75GB for all 32bit processes on SPARC. 64-bit processes have a much much larger limit.
    http://developers.sun.com/solaris/articles/solaris_memory.html
    Regards,
    Shane.

  • "could not open socket" error

    Hello:
    I am following the book "Adobe Dreamweaver CS5 with PHP" by David Powers (an excellent book I might add) and am currently going over chapter 8. (Zending email). I have completed the section concerning processing of a simple user feedback script, and I beleive I have my connector script, and code correct. My testing server is running and correctly defined in DW. When I attempt to submit the form in a browser window, I get the message "could not open socket" at the top of the  browser document window. I assume this involves adjusting a configuration file but I can not figure out where it is. Any help out there?
    My setup:
    Windows 7
    Apache2.2.17
    PHP5.3.4
    ZendFramework-1.11.4-minimal

    Boy, this one sure has me stumped.
    Despite using the amendment to the catch block that you so graciously suggested, and turning off my firewall, and antivirus software, all I get is the error message "could not open socket" at the top of the browser (various) document window (and a resetting of all fields and textarea):
    Here are my files. (I understand I will be changing my passwords, and getting a new recaptcha key, but I am desperate to fix this):
    I also amended the mail_connector.php script using the (Outgoing Mail Server: (SSL) server306.webhostingpad.com (server requires authentication) port 465) choice below with the same result.
    My hosting company provided this to me for manual setting of email:
    Manual Settings
    Mail Server Username: test1+housecalls4pets.com
    Incoming Mail Server: mail.housecalls4pets.com
    Incoming Mail Server: (SSL) server306.webhostingpad.com
    Outgoing Mail Server: mail.housecalls4pets.com (server requires authentication) port 2626
    Outgoing Mail Server: (SSL) server306.webhostingpad.com (server requires authentication) port 465
    Supported Incoming Mail Protocols: POP3, POP3S (SSL/TLS), IMAP, IMAPS (SSL/TLS)
    Supported Outgoing Mail Protocols: SMTP, SMTPS (SSL/TLS)
    library.php:
    <?php
    // Adjust the path to match the location of the library folder on your system
    $library = 'C:/php_library/ZendFramework-1.11.4-minimal/library';
    set_include_path(get_include_path() . PATH_SEPARATOR . $library);
    require_once('Zend/Loader/Autoloader.php');
    try {
      Zend_Loader_Autoloader::getInstance();
      $write = array('host'     => 'localhost',
         'username' => 'cs5write',
         'password' => 'Bow!e#CS5',
         'dbname'   => 'phpcs5');
      $read  = array('host'     => 'localhost',
         'username' => 'cs5read',
         'password' => '5T@rmaN',
         'dbname'   => 'phpcs5');
      // Comment out the next two lines if using mysqli
      // and remove the comments from the last two lines
      $dbWrite = new Zend_Db_Adapter_Pdo_Mysql($write);
      $dbRead = new Zend_Db_Adapter_Pdo_Mysql($read);
      //$dbWrite = new Zend_Db_Adapter_Mysqli($write);
      //$dbRead = new Zend_Db_Adapter_Mysqli($read);
    catch (Exception $e) {
        echo 'Class: ' . get_class($e) . ' says: ' . $e->getMessage();
    mail_connector.php:
    <?php
    $mailhost = 'smtp.mail.housecalls4pets.com';
    $mailconfig = array('auth' => 'login',
          'username' =>'[email protected]',
         'password' => 'Buffy1481',
         'port'    => '2626');
    $transport = new Zend_Mail_Transport_Smtp($mailhost, $mailconfig);
    Zend_Mail::setDefaultTransport($transport);
    process_comments.php
    <?php
    require_once('library.php');
    $errors = array();
    try {
      $public_key = '6LekzsUSAAAAAP99fQ32-j-qlp2wUWqeUc3_HvkX';
      $private_key = '6LekzsUSAAAAAHxKj135LEE9zoAxQng1A3azJYgE';
      $recaptcha = new Zend_Service_ReCaptcha($public_key, $private_key);
      if (isset($_POST['send'])) {
    // validate the user input
    if (empty($_POST['recaptcha_response_field'])) {
       $errors['recaptcha'] = 'reCAPTCHA field is required';
    } else {
       $result = $recaptcha->verify($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
       if (!$result->isValid()) {
      $errors['recaptcha'] = 'Try again';
    $val = new Zend_Validate_Alnum(TRUE);
    if (!$val->isValid($_POST['name'])) {
       $errors['name'] = 'Name is required';
    $val = new Zend_Validate_EmailAddress();
    if (!$val->isValid($_POST['email'])) {
       $errors['email'] = 'Email address is required';
    $val = new Zend_Validate_StringLength(10);
    if (!$val->isValid($_POST['comments'])) {
       $errors['comments'] = 'Required';
    if (!$errors) {
      // create and send the email
        require_once('mail_connector.php');
        $mail = new Zend_Mail('UTF-8');
        $mail->addTo('[email protected]', 'A N Other');
        $mail->setFrom('[email protected]', 'Zend Mail Test');
        $mail->setSubject('Comments from feedback form');
        $mail->setReplyTo($_POST['email'], $_POST['name']);
        $text = "Name: {$_POST['name']}\r\n\r\n";
        $text .= "Email: {$_POST['email']}\r\n\r\n";
        $text .= "Comments: {$_POST['comments']}";
        $html = "<p><strong>Name: </strong><a href='mailto:{$_POST['email']}'>{$_POST['name']}</a></p>";
        $html .= '<p><strong>Comments: </strong>' . nl2br($_POST['comments']) . '</p>';
        $mail->setBodyText($text, 'UTF-8');
        $mail->setBodyHtml($html, 'UTF-8');
        $success = $mail->send();
        if (!$success) {
          $errors = TRUE;
    } catch (Exception $e) {
      echo $e->getMessage();
    ?>
    comments.php:
    <?php
    require_once('scripts/process_comments.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Contact Us</title>
    <link href="../../styles/users_wider.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h1>Get In Touch</h1>
    <form id="form1" name="form1" method="post" action="">
      <?php if (isset($success) && !$errors) { ?>
      <p>Thank you. Your comments have been sent.</p>
      <?php } elseif (isset($success) && $errors) { ?>
      <p>Sorry, there was a problem. Please try later.</p>
      <?php } ?>
      <p>All fields are required</p>
      <p>
        <label for="name">Your name:</label>
        <input value="<?php if ($_POST && $errors) {
      echo htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8');
    }?>" type="text" name="name" id="name" />
        <span>
        <?php if ($_POST && isset($errors['name'])) {
        echo $errors['name'];
    } ?>
        </span></p>
      <p>
        <label for="email">Email address:</label>
        <input value="<?php if ($_POST && $errors) {
      echo htmlentities($_POST['email'], ENT_COMPAT, 'UTF-8');
    }?>" type="text" name="email" id="email" />
      <span>
      <?php if ($_POST && isset($errors['email'])) {
        echo $errors['email'];
    } ?>
      </span></p>
      <p>
        <label for="comments">Comments:</label>
        <textarea name="comments" id="comments" cols="45" rows="5"><?php if ($_POST && $errors) {echo htmlentities($_POST['comments'],ENT_COMPAT, 'UTF-8'); }?></textarea>
      <span>
      <?php if ($_POST && isset($errors['comments'])) {
        echo $errors['comments'];
    } ?>
      </span></p>
      <?php if (isset($errors['recaptcha'])) {
        echo "<p><span>{$errors['recaptcha']}</span></p>";
      echo $recaptcha->getHtml(); ?>
      <p>
        <input type="submit" name="send" id="send" value="Send Comments" />
      </p>
    </form>
    </body>
    </html>

  • Problem in using socket streams with encryption and decryption

    Hi,
    I am developing a client/server program with encryption and decryption at both end. While sending a message from client it should be encrypted and at the receiving end(server) it should be decrypted and vice versa.
    But while doing so i got a problem if i use both encryption and decryption at both ends. But If i use only encryption at one (only outputstream) and decryption at other end(only inputstream) there is no problem.
    Here is client/server pair of programs in which i am encrypting the outputstream of the socket in client side and decrypting the inputstream of the socket in server side.
    serverSocketDemo.java
    import java.io.*;
    import java.net.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.util.*;
    import java.util.zip.*;
    class serverSocketDemo
         public static void main(String args[])
              try
              {                    //server listening on port 2000
                   ServerSocket server=new ServerSocket(2000);
                   while (true)
                        Socket theConnection=server.accept();
                        System.out.println("Connecting from local address : "+theConnection.getLocalAddress());
                        System.out.println("Connection request from : "+theConnection.getInetAddress());
                        //Input starts from here
                        Reader in=new InputStreamReader(getNetInStream(theConnection.getInputStream()),"ASCII");
                        StringBuffer strbuf=new StringBuffer();
                        int c;
                        while (true)
                             c=in.read();
                             if(c=='\n' || c==-1)
                                  break;
                             strbuf.append((char)c);     
                        String str=strbuf.toString();
                        System.out.println("Message from Client : "+str);
                        in.close();               
                        theConnection.close();
              catch(BindException e)
                   System.out.println("The Port is in use or u have no privilage on this port");
              catch(ConnectException e)
                   System.out.println("Connection is refused at remote host because the host is busy or no process is listening on that port");
              catch(IOException e)
                   System.out.println("Connection disconnected");          
              catch(Exception e)
         public static BufferedInputStream getNetInStream(InputStream in) throws Exception
              // register the provider that implements the algorithm
              Provider sunJce = new com.sun.crypto.provider.SunJCE( );
              Security.addProvider(sunJce);
              // create a key
              byte[] desKeyDataDec = "This encryption can not be decrypted".getBytes();
              DESKeySpec desKeySpecDec = new DESKeySpec(desKeyDataDec);
              SecretKeyFactory keyFactoryDec = SecretKeyFactory.getInstance("DES");
              SecretKey desKeyDec = keyFactoryDec.generateSecret(desKeySpecDec);
              // use Data Encryption Standard
              Cipher desDec = Cipher.getInstance("DES");
              desDec.init(Cipher.DECRYPT_MODE, desKeyDec);
              CipherInputStream cin = new CipherInputStream(in, desDec);
              BufferedInputStream bin=new BufferedInputStream(new GZIPInputStream(cin));
              return bin;
    clientSocketDemo.java
    import java.io.*;
    import java.net.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.util.*;
    import java.util.zip.*;
    class clientSocketDemo
         public static void main(String args[])
              try
                   Socket theConnection=new Socket("localhost",2000);
                   System.out.println("Connecting from local address : "+theConnection.getLocalAddress());
                   System.out.println("Connecting to : "+theConnection.getInetAddress());
                   //Output starts from here               
                   OutputStream out=getNetOutStream(theConnection.getOutputStream());
                   out.write("Please Welcome me\n".getBytes());
                   out.flush();
                   out.close();
                   theConnection.close();
              catch(BindException e)
                   System.out.println("The Port is in use or u have no privilage on this port");
              catch(ConnectException e)
                   System.out.println("Connection is refused at remote host because the host is busy or no process is listening on that port");
              catch(IOException e)
                   System.out.println("Connection disconnected");          
              catch(Exception e)
         public static OutputStream getNetOutStream(OutputStream out) throws Exception
              // register the provider that implements the algorithm
              Provider sunJce = new com.sun.crypto.provider.SunJCE( );
              Security.addProvider(sunJce);
              // create a key
              byte[] desKeyDataEnc = "This encryption can not be decrypted".getBytes();
              DESKeySpec desKeySpecEnc = new DESKeySpec(desKeyDataEnc);
              SecretKeyFactory keyFactoryEnc = SecretKeyFactory.getInstance("DES");
              SecretKey desKeyEnc = keyFactoryEnc.generateSecret(desKeySpecEnc);
              // use Data Encryption Standard
              Cipher desEnc = Cipher.getInstance("DES");
              desEnc.init(Cipher.ENCRYPT_MODE, desKeyEnc);
              CipherOutputStream cout = new CipherOutputStream(out, desEnc);
              OutputStream outstream=new BufferedOutputStream(new GZIPOutputStream(cout));
              return outstream;
    Here is client/server pair in which i use both encrypting outpustream and decrypting inputstream at both ends.
    serverSocketDemo.java
    import java.io.*;
    import java.net.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.util.*;
    import java.util.zip.*;
    class serverSocketDemo
         private Cipher desEnc,desDec;
         serverSocketDemo()
              try
                   // register the provider that implements the algorithm
                   Provider sunJce = new com.sun.crypto.provider.SunJCE( );
                   Security.addProvider(sunJce);
                   // create a key
                   byte[] desKeyData = "This encryption can not be decrypted".getBytes();
                   DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
                   SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
                   SecretKey desKey = keyFactory.generateSecret(desKeySpec);
                   desEnc = Cipher.getInstance("DES");
                   desEnc.init(Cipher.ENCRYPT_MODE, desKey);
                   desDec = Cipher.getInstance("DES");
                   desDec.init(Cipher.DECRYPT_MODE, desKey);               
              catch (javax.crypto.NoSuchPaddingException e)
                   System.out.println(e);          
              catch (java.security.NoSuchAlgorithmException e)
                   System.out.println(e);          
              catch (java.security.InvalidKeyException e)
                   System.out.println(e);          
              catch(Exception e)
                   System.out.println(e);
              startProcess();
         public void startProcess()
              try
                   ServerSocket server=new ServerSocket(2000);
                   while (true)
                        final Socket theConnection=server.accept();
                        System.out.println("Connecting from local address : "+theConnection.getLocalAddress());
                        System.out.println("Connection request from : "+theConnection.getInetAddress());
                        Thread input=new Thread()
                             public void run()
                                  try
                                       //Input starts from here
                                       Reader in=new InputStreamReader(new BufferedInputStream(new CipherInputStream(theConnection.getInputStream(), desDec)),"ASCII");
                                       StringBuffer strbuf=new StringBuffer();
                                       int c;
                                       while (true)
                                            c=in.read();
                                            if(c=='\n'|| c==-1)
                                                 break;
                                            strbuf.append((char)c);     
                                       String str=strbuf.toString();
                                       System.out.println("Message from Client : "+str);
                                  catch(Exception e)
                                       System.out.println("Error caught inside input Thread : "+e);
                        input.start();
                        Thread output=new Thread()
                             public void run()
                                  try
                                       //Output starts from here
                                       OutputStream out=new BufferedOutputStream(new CipherOutputStream(theConnection.getOutputStream(), desEnc));
                                       System.out.println("it will not be printed");
                                       out.write("You are Welcome\n".getBytes());
                                       out.flush();
                                  catch(Exception e)
                                       System.out.println("Error caught inside output Thread : "+e);
                        output.start();
                        try
                             output.join();
                             input.join();
                        catch(Exception e)
                        theConnection.close();
              catch(BindException e)
                   System.out.println("The Port is in use or u have no privilage on this port");
              catch(ConnectException e)
                   System.out.println("Connection is refused at remote host because the host is busy or no process is listening on that port");
              catch(IOException e)
                   System.out.println("Connection disconnected");          
              catch(Exception e)
         public static void main(String args[])
              serverSocketDemo server=new serverSocketDemo();          
    clientSocketDemo.java
    import java.io.*;
    import java.net.*;
    import java.security.*;
    import java.security.spec.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.util.*;
    import java.util.zip.*;
    class clientSocketDemo
         private Cipher desEnc,desDec;
         clientSocketDemo()
              try
                   // register the provider that implements the algorithm
                   Provider sunJce = new com.sun.crypto.provider.SunJCE( );
                   Security.addProvider(sunJce);
                   // create a key
                   byte[] desKeyData = "This encryption can not be decrypted".getBytes();
                   DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
                   SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
                   SecretKey desKey = keyFactory.generateSecret(desKeySpec);
                   desEnc = Cipher.getInstance("DES");
                   desDec = Cipher.getInstance("DES");
                   desEnc.init(Cipher.ENCRYPT_MODE, desKey);
                   desDec.init(Cipher.DECRYPT_MODE, desKey);               
              catch (javax.crypto.NoSuchPaddingException e)
                   System.out.println(e);          
              catch (java.security.NoSuchAlgorithmException e)
                   System.out.println(e);          
              catch (java.security.InvalidKeyException e)
                   System.out.println(e);          
              catch(Exception e)
                   System.out.println(e);
              startProcess();
         public void startProcess()
              try
                   final Socket theConnection=new Socket("localhost",2000);
                   System.out.println("Connecting from local address : "+theConnection.getLocalAddress());
                   System.out.println("Connecting to : "+theConnection.getInetAddress());
                   Thread output=new Thread()
                        public void run()
                             try
                                  //Output starts from here               
                                  OutputStream out=new BufferedOutputStream(new CipherOutputStream(theConnection.getOutputStream(), desEnc));
                                  out.write("Please Welcome me\n".getBytes());
                                  out.flush();
                             catch(Exception e)
                                  System.out.println("Error caught inside output thread : "+e);
                   output.start();     
                   Thread input=new Thread()
                        public void run()
                             try
                                  //Input starts from here
                                  Reader in=new InputStreamReader(new BufferedInputStream(new CipherInputStream(theConnection.getInputStream(), desDec)),"ASCII");          
                                  System.out.println("it will not be printed");
                                  StringBuffer strbuf=new StringBuffer();
                                  int c;
                                  while (true)
                                       c=in.read();
                                       if(c=='\n' || c==-1)
                                            break;
                                       strbuf.append((char)c);     
                                  String str=strbuf.toString();
                                  System.out.println("Message from Server : "+str);
                             catch(Exception e)
                                  System.out.println("Error caught inside input Thread : "+e);
                   input.start();
                   try
                        output.join();
                        input.join();
                   catch(Exception e)
                   theConnection.close();
              catch(BindException e)
                   System.out.println("The Port is in use or u have no privilage on this port");
              catch(ConnectException e)
                   System.out.println("Connection is refused at remote host because the host is busy or no process is listening on that port");
              catch(IOException e)
                   System.out.println("Connection disconnected");          
              catch(Exception e)
         public static void main(String args[])
              clientSocketDemo client=new clientSocketDemo();     
    **** I know that the CInput tries to read some header stuff thats why i used two threads for input and output.
    Waiting for the reply.
    Thank you.

    Do not ever post your code unless requested to. It is very annoying.
    Try testing what key is being used. Just to test this out, build a copy of your program and loop the input and outputs together. Have them print the data stream onto the screen or a text file. Compare the 1st Output and the 2nd Output and the 1st Input with the 2nd Input and then do a static test of the chipher with sample data (same data which was outputted), then do another cipher test with the ciphertext created by the first test.
    Everything should match - if it does not then follow the steps below.
    Case 1: IO Loops do not match
    Case 2: IO Loops match, but ciphertext 1st run does not match loop
    Case 3: IO Loops match, 1st ciphertext 1st run matches, but 2nd run does not
    Case 4: IO Loops match, both chiphertext runs do not match anything
    Case 5: Ciphertext runs do not match eachother when decrypted correctly (outside of the test program)
    Problems associated with the cases above:
    Case 1: Private Key is changing on either side (likely the sender - output channel)
    Case 2: Public Key is changing on either side (likely the sender - output channel)
    Case 3: Private Key changed on receiver - input channel
    Case 4: PKI failure, causing private key and public key mismatch only after a good combination was used
    Case 5: Same as Case 4

  • If I copy the "lcds" folder, Tomcat starts with socket errors

    In the documentation it is said that when you create a new server-side application, you can start by copying the 'webapps/lcds' folder. I did that but then, Tomcat starts with some socket errors:
    [LCDS]SocketServer 'my-rtmp-SocketServer' failed to pre-validate desired socket settings for BindSocketAddress: 0.0.0.0:2038
    java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    [LCDS]SocketServer 'my-rtmp-SocketServer' failed to start.
    flex.messaging.LocalizedException: SocketServer 'my-rtmp-SocketServer' cannot bind to accept client connections on port '2038' because another process has already bound the port. Please ensure that multiple endpoints across all applications  are not configured to use this same port.
    Am I doing something wrong?
    Thanks,
    Borek

    What is happening is that you are getting a port conflict for the socket-based NIO and RTMP endpoints used in the channel definitions in the services-config.xml file of your new web app. The issue is that you have endpoints bound to the same port  in the LCDS web and in your new web app.
    You can deal with this one of two ways:
    Option 1: In that services-config.xml file, search on "RTMP" and "NIO" to find the channel definitions and change the port numbers to something slightly different than the ones used in the LCDS web app.
    Options 2: Move the LCDS web app out of the picture so it doesn't get loaded, and just use a template for future web apps. If you aren't using it for any of your development, there is really no reason you have to load it.
    I'll add a note about this to the documentation that talks about using the LCDS web app as a template.

  • Problem with Java Proxy and Socket Connection

    Hi Gurus!!
    I have developed a Java Proxy that connects via socket with a Server Socket application. This Server Socket application accepts more than one connection at the same time.
    When I connect the first time from my Java Proxy, the connection is correctly established. When the first connection opened, if a try a second connection, this is not established.
    I use "new Socket(SocketServer,SocketPort);" to open the connection.
    I think that all time the Java Proxy is trying to open the same connection, and this is a problem.
    Is there a way to indicate to the server that is a new connection and that the existing connections remain?
    Anybody could help me, please?
    Thanks and regards,
    Manuel Míguez.

    Sorry!!!!i must give you more information.
    The error which i have when i push the submit button is
    HTTP Status 404 -
    type Status report
    message
    descriptionThe requested resource () is not available.
    GlassFish Server Open Source Edition 3.0.1
    My thought is that the error is in this line
    String connectionURL = "jdbc:mysql://localhost/mybooking";in mysql when i write this code then the table opens with no problems:
    mysql>show databases;
    mysql>usebooking;
    mysql>showtables;
    mysql>describe booking;Furthermore i have added in my web application the library mysql JDBC driver my-sql-connector-java-5.1.6.bin.jar
    Edited by: 813355 on Nov 22, 2010 1:50 AM
    Edited by: 813355 on Nov 22, 2010 2:00 AM

  • Error in using the Socket Adapter while deploying the composite

    I am going through a Socket Adapter sample given in Oracle JCA Adapters for Sockets"Oracle Socket Adapter Hello World".
    This sample demonstrates inbound request/response and synchronous outbound request/response modes of communication using using Oracle Socket Adapter.
    The HelloWorld business process takes an input string from the Socket Adapter inbound service and
    publishes the message to the BPEL process.
    The BPEL process invokes the Socket Adapter outbound service and returns the received string using synchronous reply.
    Before going into this sample i did the configuration in the Weblogic server by following the steps below:-
    1)Log into Weblogic server console
    2)Click Deployments in the left pane for Domain Structure
    3)Click Socket Adapter.The settings for SocketAdapter page is displayed.
    4)Click the configuration tab
    5)Click the Outbound Connection Pools tab, and expand java.resource.cci.ConnectionFactory to see connection
    factories
    6)Click eis/socket/SocketAdapter
    7)Set the KeepAlive connection property to true
    8)Save the setting.
    After this i did the necessary configurations in the Socket Adapter Configuration Wizard(Inbound/Outbound).
    The BPEL process has:-
    1)A receive which receives input from a Socket Adapter which serves as an inbound synchronous service.
    2)An invoke acitvity which invokes a socket adapter which serves as a outbound synchronous service.
    3)Two Assign activites to do the necessary assignment.
    After Deploying the sample i encountered with the following errors:-
    <Sep 9, 2012 1:19:48 PM IST> <Error> <oracle.integration.platform.blocks.deploy.servlet> <SOA-21537> <Sending back error message: There was an error deploying the composite on soa_
    server1: [JCABinding] [Middleware.ServerConnection/6.0]Unable to complete unload due to: Cannot locate Java class oracle.tip.adapter.socket.SocketInteractionSpec: Cannot locate Jav
    a class oracle.tip.adapter.socket.SocketInteractionSpec..>
    Can any one please tell me the solution for this error.
    Edited by: 957910 on Sep 12, 2012 1:10 AM

    Did you find a solution for this issue. I see the same error while deploying the same very sample code.

  • No more data to read from socket error.

    Oracle Version
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - ProductionI am trying a code like below
    MERGE INTO TABLE1
    ( SELECT  ...
    FROM VIEW1 ) a UNPIVOT ("VALS" FOR cols IN ( .....columns to unpivot.......))
    where a.column1='test'
    ) b ON ( a.id=b.id)
    WHEN MATCHED THEN
    UPDATE set a.name=b.name
    when not matched then
    insert (a.id,a.name) values ( b.id,b.name);This code is giving error : No more data to read from socket error.
    But when I am trying
    MERGE INTO TABLE1
    ( SELECT  ...
    FROM VIEW1*
    where a.column1='test' ) a UNPIVOT ("VALS" FOR cols IN ( .....columns to unpivot.......))
    ) b ON ( a.id=b.id)
    WHEN MATCHED THEN
    UPDATE set a.name=b.name
    when not matched then
    insert (a.id,a.name) values ( b.id,b.name);It's working properly.
    Any idea why I am getting error with code 1?
    Edited by: Anupam_Halder on Oct 4, 2012 2:13 PM

    You need to look for an Oracle specific error code and message. The error text you have posted does not seem to be an Oracle error.
    The error however could result from an ORA-3113 end-of-file on communication channel.
    This Oracle error means that the Oracle server process servicing your request (executing SQL or PL/SQL code) ran into a fatal error (potentially an Oracle bug). The server process then proceeds with a "crash dump" - writes an error to the database instance's alert log, writes a trace file and then terminiates abnormally.
    It terminates without telling the client and without tearing down the tcp client-server connection. When the client then attempts to use this connection, the socket read fails. No data to read as the socket connection no longer exists.
    But this is speculation - we need to see the actual Oracle error (from the server or from the client driver). And you seem to be using an Oracle client that suppresses Oracle error codes and text. Which places a serious question mark over the actual usability of such client s/w for Oracle client-server.

  • Socket error 10038 on URLConnection

    We put a Java 1.2.2 applet into production on our intranet starting in April. Of the more than 800 users (all running Windows and IE), 3 have been unsuccessful in getting it to work; the appliet will not make a connection to our application server via a URLConnection to a CGI. The error returned is a connection error, code = 10038, "Socket operation on a non-socket."
    This week the applet failed for two more of our users who had been using it successfully. They both reported that a Windows application (Remedy software, I think it is their Help Desk product) had been upgraded.
    Any ideas as to why our applet fails with the 10038 on a small number of machines? Or what other environmental factors (Winsock problems?, etc.) might cause the 10038 error as evidenced by the upgrade of another application?
    Stephen

    We have same problem with 10038 error. It appears after installing Ws2help.dll in C:\Windows\System. This dll was required by "trillian", a instant messenger software. The problem disappears after removing this library.

  • Socket error in weblogic 7 when switching app to ssl

    I am supporting an app that is running on weblogic 7.0.2.0. Because of security requirements I have been asked to enable SSL access and turn off the non-SSL listen port. I can enable the SSL port without issue but when I attempt to close the non-ssl port (so that users can only access via SSL) I get the following error in the log on startup.
    ####<Dec 7, 2009 12:34:21 AM GMT> <Error> <socket> <ExecuteThread: '7' for queue: '__weblogic_admin_rmi_queue'> <kernel identity> <> <000405> <Uncaught Throwable in p
    rocessSockets
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Old socket closed and released FD before FDRecord still exists, resulting in two sockets for same FD, old socket:weblogic.socket.SSLFilter@25143a
    , new socket:weblogic.ldap.MuxableSocketLDAP@6c9f34 ]>
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Old socket closed and released FD before FDRecord still exists, resulting in two sockets for same FD, old socket:weblogic.socket.SSLFilter@25143a,
    new socket:weblogic.ldap.MuxableSocketLDAP@6c9f34 ]
    Start server side stack trace:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Old socket closed and released FD before FDRecord still exists, resulting in two sockets for same FD, old socket:weblogic.socket.SSLFilter@25143a,
    new socket:weblogic.ldap.MuxableSocketLDAP@6c9f34 ]
    at weblogic.socket.PosixSocketMuxer.read(PosixSocketMuxer.java:567)
    at weblogic.ldap.MuxableSocketLDAP.dispatch(MuxableSocketLDAP.java:148)
    at weblogic.socket.SSLFilter.dispatch(SSLFilter.java:279)
    at weblogic.socket.MuxableSocketDiscriminator.dispatch(MuxableSocketDiscriminator.java:277)
    at weblogic.socket.SSLFilter.dispatch(SSLFilter.java:279)
    at weblogic.socket.PosixSocketMuxer.deliverGoodNews(PosixSocketMuxer.java:770)
    at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:694)
    at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:23)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
    End server side stack trace
    <<no stack trace available>>
    Initially I didn't see this problem in validation, but now that I have restarted the admin server and managed servers in validation I see the same error in both environments.
    Does anyone have an idea of what might cause this error?
    Thanks,
    -Mike
    Edited by: user3862080 on Dec 8, 2009 9:07 AM

    We faced with the similar issue in WLS 7.X after below Assertion error after restoring services we were able to resolve this issue for time being as per the weblogic there is a patch provided by BEA and this sort of issue is resolved.
    This issue has been identified and updated under cars CR103525
    Regards,
    CSR
    BEA Analyst

Maybe you are looking for

  • How to fix Imac 8.1 on Windows black screen problem?

    Firstly when I originally got this machine it seemed (about 4 years ago), sometimes had my Pc forget the keys shortcuts for the Mac) Anyway over the last year I have the problem where I'd be in the middle of doing something on the Windows side then r

  • Cisco 340 (Edge) DMP can support ELO 3209L Touch Screen

    Hi Cisco Expert, Could you help to check ELO 3209L Touch Screen, i'd like to use this screen in our Digital Signs Systems (AppSpace 5. and 340 DMP), but i'm not sure about 340 DMP which can support 3209L or not, some screen model from cisco website.

  • Cannot remember admin password

    Won't let me use my apple id. Please help

  • What External Hard Drive to Buy, any Suggestions.

    Hi all, i need an external hard drive. Easily answered i hear you say, here's where it gets harder. I dont want to buy a case and a drive and then build it, i want to buy it off the shelf. I need.................... Firewire Oxford chipset 300-500 GB

  • Group Policy - Workstation Group

    Hello, I am trying to apply a windows group policy using a workstation policy package and associating it with a workstation group. When I go log in to a workstation that is a member of the workstation group after the policy has been setup and go into