Problem with socket gateway

I am trying to use the socket gateway to watch a port 1010
for all incoming data. When data comes in I want to log it. Well to
get started I just used a simple example from the docs to see if I
could get it to work. But when I try to start the gateway I get
this error:
SocketGateway(tvsocket) Error opening port 1010:
java.net.BindException: Address already in use: JVM_Bind
Does anyone know what that means?
jfill

It could mean just what it says. The port is already in use
by some other application. On Windows, you can verify that using
FPort.

Similar Messages

  • Problem with socket packaging

    There seems to be a problem with the plastic cpu clip i work as a tech in a computer store we build many systems with msi boards, the plastic clip on the 915G series most times has fallen off and pins in the cpu socket have been damaged.
    You should use a plastic insert under the cpu hood to prevent it from falling off.

    Quote
    Not sure either why DelUK thinks this is not a suitable topic for this forum.
    Probably because Del interpreted "You should use a plastic insert under the cpu hood to prevent it from falling off." to mean that "You" was MSI, and not the members of this forum. Oddly enough, I interpreted this the same way.  I don't see where Del indicated the topic was not suitable, though.
    As Del said, and as mentioned in the Forum Rules, MSI does not participate here. If you feel there is a manufacturing problem, contact MSI directly.

  • Problem with Socket Sever

    Hello,
    I have a problem with a java socket.
    I have a server application that generate random number.
    I my client application, I connected to server application and red the random number.
    My problem is in my application client only read one time. After this, the socket server application close.
    How to do the server socket wait a new request from my client application?

    Put your accept in a while ....
    while (!this.interrupted()) {
    Socket socket;
    try {
    socket = serverSocket.accept();
    if (this.isInterrupted()) {
    return;
    new ClientConnection(); ///////Do your thing here ...
    } catch (IOException e) {
    return;
    HOPE this helps

  • Problem with RD gateway manager

    Hi,
    Have some problems with manager. It used to work, but suddenly I can't connect to local server.
    Get this error:
    "The RD Gateway Managment snap-in console cannot connect to the server. To connect to this server, you must be a memeber of the local administrators group on the server."
    The user account that i'm using is a member of the local administrator group.
    Any ideas?
    The RDS server is a Win2012 server. The AD server is a win 2008 R2 server.
    Thanks
    \Kent

    Hi Kent,
    Thanks for your comment.
    For this you need to create RD Rap and RD CAP policies. When you create the RD RAP, add the user groups that you defined in the RD CAP. Also, create a new RD Gateway-managed computer group that contains both the NetBIOS names and the fully qualified domain
    names (FQDNs) of the RD Session Host servers or the RD Session Host server farm that hosts the RemoteApp programs.
    Please check below article for information.
    1. Remote Desktop Gateway Manager
    2.How To Work with RD Gateway in Windows Server 2012
    Hope it helps!
    Thanks.
    Dharmesh Solanki

  • Codec problem with one gateway

    I am having a very strange problem with one of my gateways. No matter how I set up my regions and device pools I continue to have all calls go through this gateway as G729. This would be fine except that I can't do conference calls because of codec mismatches.
    The gateway is a PRI running H323. CM 3.2.2(c) Gateway is a 3640 running 12.2.11(t)
    All regions are currently set to G711.
    I read something about a command under voice-port that sets the default codec. What I don't understand is, if this is what is causing it to go to G729, why is this the only gateway that ignores the regions.
    Any help would be appreciated.

    Cisco VoIP gateways support the codec negotiation feature. This feature provides the ability for a Cisco VoIP gateway to connect to other VoIP devices without necessarily knowing which codec is used for a call-setup. Also, this feature allows Cisco VoIP gateways to dynamically adjust to changes on remote devices. As long as the codec used by the remote VoIP device matches the capabilities-list of the Cisco VoIP gateway, the VoIP call is completed.
    The following example shows how to configure codec negotiation:
    Cisco-router# config t
    Cisco-router(config)# voice class codec 1
    !--- This sets up class 1 to be assigned to the dial peer.
    Cisco-router(config-class)#codec preference 1 g723r63
    Cisco-router(config-class)#codec preference 2 g729ar8
    Cisco-router(config-class)#codec preference 3 g711ulaw
    Cisco-router(config-class)#codec preference 4 g726r32 bytes 240
    !--- These commands define the preferred codec list using 1,2,3, and 4 to set the preference.
    Cisco-router(config)#dial-peer voice 1 voip
    Cisco-router(config-dial-peer)#voice-class codec 1
    !--- This assigns voice-class codec 1 to the dial-peer
    Cisco-router(config-dial-peer)#destination-pattern 4723155
    Cisco-router(config-dial-peer)#session target ipv4:192.168.100.1

  • Problem with Mobile Gateway 1.0 Configuration

    reffering to the config guide for mobile gateway 1.0 (https://websmp102.sap-ag.de/~sapdownload/011000358700000518422009E/Config_Guide_MGW_SP01_rev.pdf) we are facing some problems with the configuration in the DOE.
    In Chapter 4.1.1.4 a SWCV "MAS_SMARTPHONE" is mentioned, which is not available in our System, though all other steps before have been successfully executed.
    We are on SP08 and SWCV "SAP BASIS 7.10" is activated and generated.
    Does anyone know a workaround?
    Thanks in advance

    i think i located the problem in the DOE.
    When a new device is registered (by user-login from device) some LUW's are listed in the SMQ2 for that Queue. Here several dumps occur:
    --> 100 ABBTO RR014013005_DRFILLING_006 MMW_RR_RR014013005 05.11.2009 18:19:51 Syntax error in program
    ZDOECL_013_005_STRWRPR==== 0A0A001710804AF2FB270034
    0A0A001710804AF2FB270034 bgw23
    --> 100 ABBTO RR014013002_DEPQ_SERVICE MMW_RR_RR014013002 05.11.2009 18:19:53 Syntax error in program
    ZDOECL_013_002_STRWRPR==== 0A0A001710604AF2FB29000E
    0A0A001710604AF2FB29000E bgw23
    From ST22:
    Error in the ABAP application program.
    The current ABAP program "SAPLSMMW_STRWRAPPER_APIS" had to be interrupted
    because it contains
    a statement that cannot be executed.
    In the include "ZDOECL_013_002_STRWRPR========CM001 " in the line 21 of program
    "ZDOECL_013_002_STRWRPR========CP " the following syntax
    errors occur:
    "Field "INIT_FLAG" is unknown. It is neither in one of the specified ta"
    "bles nor defined by a "DATA" statement. "DATA" statement."

  • Problem with  trasparent gateway versus Microsoft SqlServer.

    Hi.
    When I declare a cursor into PL-SQL procedure that select records from a SQL-SERVER table linked using a trasparent gateway.
    I have two problem:
    -1- I' m unable to update the linked table. I receve e timeout exception.
    -2- whe I execute the second fatch operation I receve ad error : invalid cursor.
    Trasparent gateway is configured as two_fase_commit.
    Can Anyone help me?
    Best regards.
    Vincenzo

    Hallo
    Yes I've tired ad it correctly work. But when I exit from cursor without make commit, and I run this simple update query (that works in sql/plus)
    "update lsruni_ser@anaconda set "lsruni_ser_flag_elab" = 'Y' where "lsruni_ser_flag_elab" = 'Y';" I receve a timout messagge from SQL SERVER.
    I HAVE GREAT PROBLEM WITH INSERT QUERY USED IN A PL-SQL PROCEDURE.
    Thank You for support.
    Vincenzo

  • Problem with socket cross domain

    Hi guys,
    This is my cross domain file:
    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
    <!-- Policy file for xmlsocket://socks.example.com -->
    <cross-domain-policy>
       <site-control permitted-cross-domain-policies="*"/>
       <allow-access-from domain="localhost" to-ports="80" />
    </cross-domain-policy>
    I am placing it in my server.
    From flex i am running this:
    Security.loadPolicyFile("my server address");
    And yet I am getting this event:
    SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"
    What can I do?

    Hello ILikeMyScreenNameNdCoffee,
    I had the same problem with XMLSocket and I used a policy server that runs
    on the remote server on port 843 and from Flex I load file before connecting
    the xmlsocket Security.loadPolicyFile("my server address:843"). If you want
    I can upload a version of my policy server or you can use the server policy
    from here
    http://www.broculos.net/tutorials/how_to_make_a_multi_client_flash_java_server/20080320/en
    Also you can read here more about file policy:
    http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_04.html.
    On Thu, Aug 19, 2010 at 5:40 PM, ILikeMyScreenNameNdCoffee <[email protected]

  • Problem with socket permissions!

    Hi All!
    I'm developing an applet that displays an image after downlading it from a server; this server is different from the server I download the applet from, so I have problems with security. In fact I get the following exception:
    java.security.AccessControlException: access denied (java.net.SocketPermission 172.16.1.22:8080 connect,resolve)
    I'm using:
    - Java Plugin 1.3;
    - Netscape 7.0;
    - IE 6;
    I've tried to self-sign the applet but with no results (maybe I cannot use selfsigned certificate with java plugin 1.3);
    After that I've created a new policy file ("MyPolicy" file)and mentioned it into:
    C:\Program Files\JavaSoft\JRE\1.3.1_03\lib\security\java.policy
    but it didn't resolve my problem (maybe I'm doing something wrong in creating my policy file??!!).
    Which steps do I have to follow in order to make my applet connect to images server without security problems?
    Thanks so much in advance,
    Carlo

    1.     Compile the applet
    2.     Create a JAR file
    3.     Generate Keys
    4.     Sign the JAR file
    5.     Export the Public Key Certificate
    6.     Import the Certificate as a Trusted Certificate
    7.     Create the policy file
    8.     Run the applet
    Susan
    Susan bundles the applet executable in a JAR file, signs the JAR file, and exports the public key certificate.
    1.     Compile the Applet
    In her working directory, Susan uses the javac command to compile the SignedAppletDemo.java class. The output from the javac command is the SignedAppletDemo.class.
    javac SignedAppletDemo.java
    2.     Make a JAR File
    Susan then makes the compiled SignedAppletDemo.class file into a JAR file. The -cvf option to the jar command creates a new archive (c), using verbose mode (v), and specifies the archive file name (f). The archive file name is SignedApplet.jar.
    jar cvf SignedApplet.jar SignedAppletDemo.class
    3.     Generate Keys
    Susan creates a keystore database named susanstore that has an entry for a newly generated public and private key pair with the public key in a certificate. A JAR file is signed with the private key of the creator of the JAR file and the signature is verified by the recipient of the JAR file with the public key in the pair. The certificate is a statement from the owner of the private key that the public key in the pair has a particular value so the person using the public key can be assured the public key is authentic. Public and private keys must already exist in the keystore database before jarsigner can be used to sign or verify the signature on a JAR file.
    In her working directory, Susan creates a keystore database and generates the keys:
    keytool -genkey -alias signFiles -keystore susanstore -keypass kpi135 -dname "cn=jones" -storepass ab987c
    This keytool -genkey command invocation generates a key pair that is identified by the alias signFiles. Subsequent keytool command invocations use this alias and the key password (-keypass kpi135) to access the private key in the generated pair.
    The generated key pair is stored in a keystore database called susanstore (-keystore susanstore) in the current directory, and accessed with the susanstore password (-storepass ab987c).
    The -dname "cn=jones" option specifies an X.500 Distinguished Name with a commonName (cn) value. X.500 Distinguished Names identify entities for X.509 certificates.
    You can view all keytool options and parameters by typing:
    keytool -help
    4.     Sign the JAR File
    JAR Signer is a command line tool for signing and verifying the signature on JAR files. In her working directory, Susan uses jarsigner to make a signed copy of the SignedApplet.jar file.
    jarsigner -keystore susanstore -storepass ab987c -keypass kpi135 -signedjar SSignedApplet.jar SignedApplet.jar signFiles
    The -storepass ab987c and -keystore susanstore options specify the keystore database and password where the private key for signing the JAR file is stored. The -keypass kpi135 option is the password to the private key, SSignedApplet.jar is the name of the signed JAR file, and signFiles is the alias to the private key. jarsigner extracts the certificate from the keystore whose entry is signFiles and attaches it to the generated signature of the signed JAR file.
    5.     Export the Public Key Certificate
    The public key certificate is sent with the JAR file to the whoever is going to use the applet. That person uses the certificate to authenticate the signature on the JAR file. To send a certificate, you have to first export it.
    The -storepass ab987c and -keystore susanstore options specify the keystore database and password where the private key for signing the JAR file is stored. The -keypass kpi135 option is the password to the private key, SSignedApplet.jar is the name of the signed JAR file, and signFiles is the alias to the private key. jarsigner extracts the certificate from the keystore whose entry is signFiles and attaches it to the generated signature of the signed JAR file.
    5: Export the Public Key Certificate
    The public key certificate is sent with the JAR file to the whoever is going to use the applet. That person uses the certificate to authenticate the signature on the JAR file. To send a certificate, you have to first export it.
    In her working directory, Susan uses keytool to copy the certificate from susanstore to a file named SusanJones.cer as follows:
    keytool -export -keystore susanstore -storepass ab987c -alias signFiles -file SusanJones.cer
    Ray
    Ray receives the JAR file from Susan, imports the certificate, creates a policy file granting the applet access, and runs the applet.
    6.     Import Certificate as a Trusted Certificate
    Ray has received SSignedApplet.jar and SusanJones.cer from Susan. He puts them in his home directory. Ray must now create a keystore database (raystore) and import the certificate into it. Ray uses keytool in his home directory /home/ray to import the certificate:
    keytool -import -alias susan -file SusanJones.cer -keystore raystore -storepass abcdefgh
    7.     Create the Policy File
    The policy file grants the SSignedApplet.jar file signed by the alias susan permission to create newfile (and no other file) in the user's home directory.
    Ray creates the policy file in his home directory using either policytool or an ASCII editor.
    keystore "/home/ray/raystore";
    // A sample policy file that lets a JavaTM program
    // create newfile in user's home directory
    // Satya N Dodda
    grant SignedBy "susan"
         permission java.security.AllPermission;
    8.     Run the Applet in Applet Viewer
    Applet Viewer connects to the HTML documents and resources specified in the call to appletviewer, and displays the applet in its own window. To run the example, Ray copies the signed JAR file and HTML file to /home/aURL/public_html and invokes Applet viewer from his home directory as follows:
    Html code :
    </body>
    </html>
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width="600" height="400" align="middle"
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,1,2">
    <PARAM NAME="code" VALUE="SignedAppletDemo.class">
    <PARAM NAME="archive" VALUE="SSignedApplet.jar">
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    </OBJECT>
    </body>
    </html>
    appletviewer -J-Djava.security.policy=Write.jp
    http://aURL.com/SignedApplet.html
    Note: Type everything on one line and put a space after Write.jp
    The -J-Djava.security.policy=Write.jp option tells Applet Viewer to run the applet referenced in the SignedApplet.html file with the Write.jp policy file.
    Note: The Policy file can be stored on a server and specified in the appletviewer invocation as a URL.
    9.     Run the Applet in Browser
    Download JRE 1.3 from Javasoft

  • Trouble with socket gateway and an as3 xmlsocket connection

    I succesfully set up the socket gateway and am able to conect to the CF socket gateway and send data from flash to the gateway.
    The error I keep getting is when I add return value to the "onIncomingMessage"... cf error always logs "Cannot send outgoing message. OriginatorID "123124124" is not a valid socket id.
    I am passing the originatorID as in the docs.... my question is what is a valid originatorID?
    <cffunction name="onIncomingMessage" output="no">
    <cfargument name="CFEvent" type="struct" required="yes">
    <!--- Create a return structure that contains the message. --->
    <!--- Get the message. --->
       <cfset message="#CFEvent.Data.message#">
       <!--- Where did it come from? --->
       <cfset orig="#CFEvent.OriginatorID#">
    <cfset retValue = structNew()>
    <cfset retValue.OriginatorID = orig>
    <cfset retValue.MESSAGE = message>
    <!--- Send the return message back. --->
    <cfreturn retValue>
    </cffunction>
    I really hope I can get an answer hardly any docs or anything online on how to correctly return a message via a socket gateway.
    Thank you.

    I succesfully set up the socket gateway and am able to conect to the CF socket gateway and send data from flash to the gateway.
    The error I keep getting is when I add return value to the "onIncomingMessage"... cf error always logs "Cannot send outgoing message. OriginatorID "123124124" is not a valid socket id.
    I am passing the originatorID as in the docs.... my question is what is a valid originatorID?
    <cffunction name="onIncomingMessage" output="no">
    <cfargument name="CFEvent" type="struct" required="yes">
    <!--- Create a return structure that contains the message. --->
    <!--- Get the message. --->
       <cfset message="#CFEvent.Data.message#">
       <!--- Where did it come from? --->
       <cfset orig="#CFEvent.OriginatorID#">
    <cfset retValue = structNew()>
    <cfset retValue.OriginatorID = orig>
    <cfset retValue.MESSAGE = message>
    <!--- Send the return message back. --->
    <cfreturn retValue>
    </cffunction>
    I really hope I can get an answer hardly any docs or anything online on how to correctly return a message via a socket gateway.
    Thank you.

  • Problem with socket and Threads

    Hi,
    I have coded a package that sends an sms via a gateway.
    Here is what is happening:
    * I create a singleton of my SMSModule.
    * I create an sms object.
    * I put the object in a Queue.
    * I start a new Thread in my sms module that reads sms from queue.
    * I connect to sms gateway.
    * I send the sms.
    * I disconnect from socket! This is where things go wrong and I get the following error (see below).
    I have a zip file with the code so if you have time to take a look at it I would appreciate it.
    Anyway all hints are appreciated!
    //Mikael
    GOT: !LogoffConf:
    mSIP Kommando var: !LogoffConf
    CoolFlix log: MSIPProtocolHandler;setLoggedin(false)
    We got LogOffConf
    Waiting ......for thread to die
    java.net.SocketException: Socket operation on nonsocket: JVM_recv in
    socket input stream read
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:116)
    at
    sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:405)

    Off the top of my head, probably the garbage collector cleared your SMSModule coz all classes loaded through other classloaders will be unloaded when that classloader is unloaded.
    mail in the code if you want me to look at it with greater detail.

  • I suppose it is the problem with socket connection,Please help

    Hi,
    I'm trying to build a chat server in Java on Linux OS.I've created basically 2 classes in the client program.The first one shows the login window.When we enter the Login ID & password & click on the ok button,the data is sent to the server for verification.If the login is true,the second class is invoked,which displays the messenger window.This class again access the server
    for collecting the IDs of the online persons.But this statement which reads from the server causes an exception in the program.If we invoke the second class independently(ie not from 1st class) then there is no problem & the required data is read from the server.Can anyone please help me in getting this program right.I'm working on a p4 machine with JDK1.4.
    The Exceptions caused are given below
    java.net.SocketException: Connection reset by peer: Connection reset by peer
    at java.net.SocketInputStream.SocketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:119)
         at java.io.InputStreamReader$CharsetFiller.readBytes(InputStreanReader.java :339)
         at java.io.InputStreamReader$CharsetFiller.fill(InputStreamReader.java:374)
         at java.io.InputStreamReader.read(InputStreamReader.java:511)
         at java.io.BufferedReader.fill(BufferedReader.java:139)
         at java.io.BufferedReader.readLine(BufferedReader.java:299)
         at java.io.BufferedReader.readLine(BufferedReader.java:362)
         at Login.LoginData(Login.java:330)
         at Login.test(Login.java:155)
         at Login$Buttonhandler.actionPerformed(Login.java:138)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1722)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:17775)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:4141)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:253)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:261)
         at java.awt.Component.processMouseEvent(Component.java:4906)
         at java.awt.Component.processEvent(component.java:4732)
         at java.awt.Container.processEvent(Container.java:1337)
         at java.awt.component.dispatchEventImpl(Component.java:3476)
         at java.awt.Container.dispatchEventImpl(Container.java:1399)
         at java.awt.Component.dispatchEvent(Component.java:3343)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3302)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3014)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2967)
         at java.awt.Container.dispatchEventImpl(Container.java:1373)
         at java.awt.window.dispatchEventImpl(Window.java:1459)
         at java.awt.Component.dispatchEvent(Component.java:3343)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:439)
         at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:131)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
         My program looks somewhat like this :
    1st class definition:
    public class Login extends Jframe// Login is the name of the first class;
    Socket connection;
    DataOutputStream outStream;
    BufferedReader inStream;
    Frame is set up here
    public class Buttonhandler implements ActionListener
    public void actionPerformed(ActionEvent e) {
    String comm = e.getActionCommand();
    if(comm.equals("ok")) {
    check=LoginCheck(ID,paswd);
    test();
    public void test() //checks whether the login is true
    if(check)
    new Messenger(ID);// the second class is invoked
    public boolean LoginCheck(String user,String passwd)
    //Enter the Server's IP & port below
    String destination="localhost";
    int port=1234;
    try
    connection=new Socket(destination,port);
    }catch (UnknownHostException ex){
    error("Unknown host");
    catch (IOException ex){
    ex.printStackTrace ();
    error("IO error creating socket ");
    try{
    inStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    outStream=new DataOutputStream(connection.getOutputStream());
    }catch (IOException ex){
    error("IO error getting streams");
    ex.printStackTrace();
    System.out.println("connected to "+destination+" at port "+port+".");
    BufferedReader keyboardInput=new BufferedReader(new InputStreamReader(System.in));
    String receive=new String();
    try{
    receive=inStream.readLine();
    }catch(IOException ex){ error("Error reading from server");}
    if(receive.equals("Logintrue"))
    check=true;
    else
    check=false;
    try{
    inStream.close();
    outStream.close();
    connection.close();
    }catch (IOException ex){
    error("IO error closing socket");
    return(check);
    // second class is defined below
    public class Messenger
    Socket connect;
    DataOutputStream outStr;
    BufferedReader inStr;
    public static void main(String args[])
    { Messenger mes = new Messenger(args[0]);}
    Messenger(String strg)
    CreateWindow();
    setupEvents();
    LoginData(strg);
    fram.show();
    void setupEvents()
    fram.addWindowListener(new WindowHandler());
    login.addActionListener(new MenuItemHandler());
    quit.addActionListener(new MenuItemHandler());
    button.addActionListener(new Buttonhandle());
    public void LoginData(String name)
    //Enter the Server's IP & port below
    String dest="localhost";
    int port=1234;
    int r=0;
    String str[]=new String[40];
    try
    connect=new Socket(dest,port);
    }catch (UnknownHostException ex){
    error("Unknown host");
    catch (IOException ex){
    ex.printStackTrace ();
    error("IO error creating socket ");
    try{
    inStr = new BufferedReader(new InputStreamReader(connect.getInputStream()));
    outStr=new DataOutputStream(connect.getOutputStream());
    }catch (IOException ex){
    error("IO error getting streams");
    ex.printStackTrace();
    String codeln=new String("\n");
    try{
    outStr.flush();
    outStr.writeBytes("!@*&!@#$%^");//code for sending logged in users
    outStr.writeBytes(codeln);
    outStr.write(13);
    outStr.flush();
    String check="qkpltx";
    String receive=new String();
    try{
    while((receive=inStr.readLine())!=null) //the statement that causes the exception
    if(receive.equals(check))
    break;
    else
         str[r]=receive;
         r++;
    }catch(IOException ex){ex.printStackTrace();error("Error reading from socket");}
    catch(NullPointerException ex){ex.printStackTrace();}
    } catch (IOException ex){ex.printStackTrace();
    error("Error reading from keyboard or socket ");
    try{
    inStr.close();
    outStr.close();
    connect.close();
    }catch (IOException ex){
    error("IO error closing socket");
    for(int l=0,k=1;l<r;l=l+2,k++)
    if(!(str[l].equals(name)))
    stud[k]=" "+str[l];
    else
    k--;
    public class Buttonhandle implements ActionListener
    public void actionPerformed(ActionEvent e) {
    //chat with the selected user;
    public class MenuItemHandler implements ActionListener
    public void actionPerformed(ActionEvent e)
    String cmd=e.getActionCommand();
    if(cmd.equals("Disconnect"))
    //Disconnect from the server
    else if(cmd.equals("Change User"))
         //Disconnect from the server & call the login window
    else if(cmd.equals("View Connection Details"))
    //show connection details;
    public class WindowHandler extends WindowAdapter
    public void windowClosing(WindowEvent e){
    //Disconnect from server & then exit;
    System.exit(0);}
    I�ll be very thankful if anyone corrects the mistake for me.Please help.

    You're connecting to the server twice. After you've successfully logged in, pass the Socket to the Messenger class.
    public class Messenger {
        Socket connect;
        public static void main(String args[]) {
            Messenger mes = new Messenger(args[0]);
        Messenger(Socket s, String strg) {
            this.connect = s;
            CreateWindow();
            setupEvents();
            LoginData(strg);
            fram.show();
    }

  • Problem with socket responses with flex

    Hi, I am using the code below to connect to an IMAP server.
    When I telnet to the server and use the commands that I am sending in the code, the rsponses are correct.
    However, when I run the code below, I only obtain the ready and logged in responses as shown below.
    Any ideas why I am not receiving the full set of responses from the socket?
    Thanks in advance fro your advice.
    The following is the output from the code:
    +++++++++++++++++ START SENDING IMAP DATA +++++++++++++++++++++++++
    sent: . login user1 myPassword
    sent: . status INBOX (messages)
    sent: . select INBOX
    +++++++++++++++++ END SENDING IMAP DATA +++++++++++++++++++++++++
    ++++++++ [IMAP START]
    Response is: * OK Dovecot ready.
    [IMAP END] +++++++++
    ++++++++ [IMAP START]
    Response is: . OK Logged in.
    [IMAP END] +++++++++
    The code is:
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx"
       applicationComplete="init()">
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
    <![CDATA[
    public var dataStr:String;
    private var socket:Socket;
    private var serverURL:String= "dead.org";
    private var serverPort:int = 143;
    private var serverResponse:ByteArray = new ByteArray();
    private function init():void
      this.serverURL = serverURL;
      this.serverPort = serverPort;
      socket = new Socket();
      socket.addEventListener(ProgressEvent.SOCKET_DATA,handleNewIMAPData); //Event when socket receives new data
      this.connectToServer();
      sendIMAPdata();
    private function sendString(dataStr:String):void
      var bytes:ByteArray = new ByteArray();
      bytes.writeMultiByte(dataStr, "UTF-8");
      socket.writeBytes(bytes);
      socket.flush();
      trace("sent: " + dataStr);
    public function sendIMAPdata():void
      trace("\t +++++++++++++++++ START SENDING IMAP DATA +++++++++++++++++++++++++");
      dataStr =". login user1 myPassword" + "\r\n";
      sendString(dataStr);
      dataStr =". status INBOX (messages)" + "\r\n";
      sendString(dataStr);
      dataStr =". select INBOX" + "\r\n";
          sendString(dataStr);
      trace("\t +++++++++++++++++ END SENDING IMAP DATA +++++++++++++++++++++++++");
    private function handleNewIMAPData(event:ProgressEvent):void
      var numBytes:int = socket.bytesAvailable;
      serverResponse = new ByteArray();
      while(socket.bytesAvailable)
        var byte:int = socket.readUnsignedByte();
    serverResponse.writeByte(byte);
      var response:String = serverResponse.toString();
      trace(" ++++++++ [IMAP START]\n Response is: " + response + "[IMAP END] +++++++++\n");
    private function connectToServer():void
      socket.connect(serverURL, serverPort);
    ]]>
    </fx:Script>
    </s:WindowedApplication>

    When I run telnet, the console responses are the same as the tcpdump messages.
    When I run the program, the messages from tcpdump match the messages in my trace statements.
    The messages from telnet and running the program are different:-)
    I can only assume (at the moment) that I am sending multiple messages too quickly(?), but I did a quick and dirty big "for loop" to slow down the sending of subsequent messages, but with no resulting change in the programs behaviour.
    So, still thinking about the problem -  unfortunately.

  • Problem with socket programming(Vista)

    I'm not sure if this has something to do with windows vista.
    I wrote simple echo client and server programs and the client program contains these lines
    String hostname="172.16.54.22"; //My comp's IP
    int portNo=6666;
    mySocket=new Socket(hostname, portNo);
    Now the problem is that the client program is able to communicate with the server only when I run both of them in xp machines or if I run the server in vista and client in xp. The client is not able to connect to the server when both the client and server are running in a vista machine or if the server is running in xp and client in vista.
    It'd be nice if any of you could throw some light on this issue.
    PS:
    It doesn't work even if I turn the firewall off
    The programs work well when I give hostname="localhost" or hostname="127.0.0.1"
    Here are my programs
    //EchoClient.java
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class EchoClient
         public static void main(String args[])
              String hostname="172.16.54.25"; //My ip address
              int portNo=6666;
              //if(args[1]
              //PrintWriter out=null;
              Socket mySocket=null;
              BufferedReader networkIn=null;
              BufferedReader userIn=null;
              PrintWriter sockOut=null;
              try
                   mySocket=new Socket(hostname, portNo);
                   networkIn=new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
                   userIn=new BufferedReader(new InputStreamReader(System.in));
                   sockOut= new PrintWriter(mySocket.getOutputStream());
                   System.out.println("Connected to Echo Server\n");
                   System.out.println("Enter a series of lines (\"end\" to exit)\n");
                   while(true)
                        String myLine=userIn.readLine();
                   //     System.out.println(myLine);
                        if(myLine.equals("end"))
                             break;
                        sockOut.println(myLine);
                        sockOut.flush();
                        System.out.println(networkIn.readLine());
              catch(IOException exc)
                   System.err.println(exc);
              finally
                   try{
                   if(networkIn!=null) networkIn.close();
                   if(sockOut!=null) sockOut.close();}
                   catch(IOException exc){ }
                   EchoServer.java
    //EchoServer.java
    import java.io.*;
    import java.net.*;
    class EchoServer
         public static void main(String args[])
              int portNo=6666;
              ServerSocket serverSock=null;
              try
                   serverSock=new ServerSocket(portNo);
                   System.out.println("Echo Server Started\n\n");
                   while(true)
                        Socket clientSock=serverSock.accept();
                        new Thread(new EchoServerThread(clientSock)).start();
              catch(IOException exc)
                   System.err.println(exc);
         EchoServerThread.java
    //EchoServerThread.java
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class EchoServerThread implements Runnable
         public Socket clientSock;
         EchoServerThread(Socket sock)
              clientSock=sock;
         public void run()
              System.out.println("\nAccepted Connection from a Client");
              try{
              BufferedReader in=new BufferedReader(new InputStreamReader(clientSock.getInputStream()));
              BufferedReader userIn=new BufferedReader(new InputStreamReader(System.in));
              PrintWriter out= new PrintWriter(clientSock.getOutputStream());
                        /*In sockIn=new In(clientSock);
              Out sockOut=new Out(clientSock);*/
              String str;
              while((str=in.readLine())!=null)
                   out.println(str);
                   out.flush();
              System.out.println("Closing Connection from a Client");
              out.close();
              in.close();
              catch(IOException exc)
                   System.err.println(exc);
         

    Sorry everyone but I'd been giving a wong IP address thinking it's my own. The problem's solved.
    Thanks for the response Peter.

  • Problem with Socket Client - Intermittent Truncated Response in AIX

    {color:#0000ff}Hi guru
    I have written on Socket Client method below to send request byte[] to Host and receive response byte[] from Host.
    For this particular response, I'm expecting Host to return me byte[] with length 2274.
    My problem is intermittently I received truncated message byte[] from Host with length only 1392. Sometimes I received full 2274 message, sometimes I received 1392 length. I tested in continual of 10 times by sending the same request to host, intermittently received truncated response message.
    My real problem is that this only happened in {color:#ff0000}AIX {color}machine. With the same class, I tested on {color:#ff0000}Windows {color}platform and i received full response message byte[] with 2274 lenght always. Therefore, im counting out the possibilities that Host might send me truncated message.
    Can anyone pls help to tell me how should I proceed to troubleshoot this problem in AIX? Is possible for me to trace what coming in?
    {color}
    public byte[] sendToHost(byte[] requestMessage, String requestId, String localTxnCode) throws Exception {
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    long startTime = 0;
    long elapsed = 0;
    try {
    LogManager.log(LogManager.DEBUG, Constants.DEFAULT_LOGGER_NAME, requestId, "[" + localTxnCode + "] To connect and send message to Host hostAddr=[" + hostAddr + "], hostPort=[" + hostPort
    + "]");
    startTime = System.currentTimeMillis();
    hostSocket = new Socket(InetAddress.getByName(hostAddr), hostPort);
    hostSocket.setSoTimeout(timeOut);
    byte responseData[] = new byte[4096];
    bis = new BufferedInputStream(hostSocket.getInputStream());
    bos = new BufferedOutputStream(hostSocket.getOutputStream());
    bos.write(requestMessage);
    bos.flush();
    int length = bis.read(responseData);
    elapsed = System.currentTimeMillis() - startTime;
    ARBAdapterUtil.log(LogManager.DEBUG, Constants.DEFAULT_LOGGER_NAME, requestId, "[" + localTxnCode + "] Received message from Host length=[" + length + "]");
    // The response byte must not be 4096 everytime
    byte[] returnByte = new byte[length];
    for (int i = 0; i < length; i++) {
    returnByte[i] = responseData;
    return returnByte;
    } catch (BindException b) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: BindException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + b.getClass().getName() + " Error message=" + b.getMessage());
    } catch (ConnectException c) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: ConnectException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + c.getClass().getName() + " Error message=" + c.getMessage());
    } catch (NoRouteToHostException nrth) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: NoRouteToHostException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + nrth.getClass().getName() + " Error message="+ nrth.getMessage());
    } catch (SocketTimeoutException se) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketTimeoutException("Socket Exception: SocketTimeoutException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + se.getClass().getName() + " Error message=" + se.getMessage());
    } catch (SocketException s) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new SocketException("Socket Exception: SocketException IP=" + hostAddr + " PORT=" + hostPort + " Error type=" + s.getClass().getName() + " Error message=" + s.getMessage());
    } catch (Exception e) {
    elapsed = System.currentTimeMillis() - startTime;
    throw new Exception("Unknown Exception: Exception IP=" + hostAddr + " PORT=" + hostPort + "Error type=" + e.getClass().getName() + " Error message=" + e.getMessage());
    } finally {
    try {
    ARBAdapterUtil.log(LogManager.INFO, Constants.DEFAULT_LOGGER_NAME, requestId, "ARBConnection.sendToHost() [" + localTxnCode + "] Time Elapsed via Socket in millisecond = [" + elapsed + "]");
    if (bis != null) {
    bis.close();
    bis = null;
    if (bos != null) {
    bos.close();
    bos = null;
    } catch (Exception e) {
    LogManager.log(LogManager.ERROR, Constants.DEFAULT_LOGGER_NAME, requestId, "ARBConnection.sendToHost() [" + localTxnCode + "] Exception during closing BufferedInputStream and BufferedOutputStream");

    I tried to use DataInputStream.readFully(byte[]). However, I could not retrieve a single byte from Host. It won't return until it fills the buffer, or EOS occurs. Isn't that what you wanted?
    You need to believe it here. Either the sending application or Java or the sending TCP stack or the intervening routers or the receiving TCP stack or Java or the receiver can break up the transmission into 1 byte reads and there is nothing you can do about it at the receiver except what I said. BufferedInputStream will mask the effect to some extent but you still have to code under that assumption. You don't have any choice about this.

Maybe you are looking for

  • How do I set up backup for multiple iphones (40 ) in one Itune?

    We will as soon as IP5 is released transfer all of our users from IP3/4 (40+) and to make that progress smoothly we want to backupp all IP's on one computer. Is it possible to backup multible iphones/Ipads in one Itune? How do I set it up? /Anders

  • Why can I only sync SD version of movie to iPhone 4?

    A few days ago, I bought The Lion King (HD) from the iTunes store app on iPhone 4.  I was almost certain I had enough space, but when I checked my phone the next morning, the download stopped prematurely due to not having enough space.  So I had to t

  • Framerate problem after burning PAL Blu-ray

    Hi folks, bit of a rookie here. Usually try to work my way around things but this is a new area for me and I'm a little stumped! Basically I'm using Encore CS5 to burn a Blu-ray from footage rendered from Final Cut. The footage is from a Sony HDV cam

  • How can I contact the administration for cancelling an invoice?

    Hi everyone, first of all sorry for my english. I just bought AbodeExportPDF but I made a mistake: I clicked twice on the button "buy now", I rightly received two invoices. How can I contact the administration for cancelling one of the invoices? Than

  • Error message "Invalid mobile number" when changin...

    I have added my mobile phone number to be my identification number when calling and texting. That was 2 years ago. Last year a nationwide change on all Qatari number was performed to increase its length by repeating the first digit. More info can be