How to run a datagram socket client and server program

hi,
I am new to socket programming. I am following the tutorial of sun for socket programming...The link is
http://java.sun.com/docs/books/tutorial/networking/datagrams/clientServer.html
I have understood the concept, but the problem is i cannot run the program. I am using netbeans and i have created a package and stored the files QuoteServer,QuoteServerThread, QuoteClient in this package. How can i make the server program run first and then client program in netbeans
kindly help me
Thankyou

I think you are trying to run both server and client
on one machine!!!
It is impossible, your server is blocking the port to
send packets, so you must run client on another
computer!!!It's not impossible to run a client and server on the same machine just for testing or as a demo. Just have the server listen on one port and the client use a different port.
No need to use 2 seperate computers. I've done it one computer before without a problem.
Nick

Similar Messages

  • Wanted SOAP client and server examples

    I am unable to run the SOAP client and server programs.
    Can anybody help me by providing some simple soap examples of both
    client and server and also how to deploy them.

    JAX-WS has a number of samples as does NetBeans. Check out http:/jax-ws.dev.java.net and http://www.netbeans.org/kb/55/websvc-jax-ws.html

  • How to handle when Client and server write to the socket at the same time

    Hi all,
    I'm writing a socket communication when client and server may write information the the socket at the same time. I look every where but the samples from the internet only shows example of server replies to client after receiving requests from clients.
    Let's say that:
    Client 1 ->Socket 1 -> Server 1
    Now if there are two threads in the server, one blocked waiting for the input from client on socket 1, the second one write something on the socket to client 1, is it possible?
    And if it's possible, if at the time Server 1 writes information to Client 1, Client 1 writes some information to Server 1 too, will there be any conflict problem or the socket could handle that two ways communication simultaneously?
    It's critical questions for me. Thanks for your help.

    I really use Server Client paradigm. However, beside the request, response mechanism, there is also an additional mechanism called update which server periodically send information update to client without the need for a request from client.
    So you suggest client should initiate 2 sockets, one for request and response, one for receiving update from the server? Will this work?

  • Socket communication between client and server

    Hi all,
    I am doing an assignment for communication between java client and java server using sockets. This communication is in the form of XML documents. I am facing a problem in this communication.
    Actually at Server side I'm creating an XML document(Document type object) using DocumentBuilderFactory in javax.xml.parsers package and transforming this Document into a stream using StreamResult.
    My code is :
    Transformer xmlTransformer = TransformerFactory.newInstance().newTransformer();
    StreamResult xmlString = new StreamResult(currentClientHandler.getSocketOutputStream());
    DOMSource xmlDocSource = new DOMSource(xmlDocument); // xmlDocument is Document type reference
    xmlTransformer.transform(xmlDocSource, xmlString);
    so, this xmlString(i.e. StreamResult) is passed directly into the output stream. Here I need to close() output stream after transform() call to help SAX parser to know about end of stream.
    Now at Client side, I am parsing this stream using SAX parser. It parses this correctly. But when sending some another data back to Server when client opens output stream, it given Socket closed exception. I know that closing input or output stream closes socket. But in my problem, I have to send data in streams and not by using files or byte[] etc.
    So what is nearest solution to problem ??
    Plz help me. Any kind of help will be greatly appreciated.

    hi
    thanks for ur reply.
    I didnt get any error msg while getting the back the datas.
    Actually i divided my application into two parts.
    My application will act as both server and client.
    server ll get the browser request and send to the client and the client will send that data to the c++ server.
    Im able to do that.and unable to get the data from server.
    Didnt get any error.
    can u tell me how to make an application to act as both client and server.
    I think im wrong in that part.
    thanks a lot

  • How to run a sample Jolt client

    Can any one explain me how to run a sample jolt client.
    Iam trying to run the following jolt client code ToUpper.java at the command prompt but I am getting the following error.I am getting the same error when i run the Jrepository Applet RE.html.
    D:\ToUpper>javac ToUpper.java
    D:\ToUpper>java ToUpper
    bea.jolt.SessionException: Cannot connect to any //localhost:3050.
    Reason:NwHdlr: Network Error: chkauth: J_CHECKAUTH FAILED
    at bea.jolt.JoltSessionAttributes.getDomainInfoJoltSessionAttributes.java:584)
    at bea.jolt.JoltSessionAttributes.checkAuthenticationLevel(JoltSessionAttributes.java:507)
    at ToUpper.main(ToUpper.java:20).
    I have the tlistener running and provided apppassword and userpassword as my System login password where I have the complete Tuxedo Installation(server and client). Please see the attached sample jolt client program I am trying to run. I am not sure what configuration Settings I need to do.
    ToUpper.java
    /* Copyright 1996 BEA Systems, Inc. All Rights Reserved */
    import bea.jolt.*;
    public class ToUpper
    public static void main (String[] args)
    JoltSession session;
    JoltSessionAttributes sattr;
    JoltRemoteService toupper;
    JoltTransaction trans;
    String userName=null;
    String userPassword=null;
    String appPassword=null;
    String userRole="myapp";
    String outstr;
              try{
    sattr = new JoltSessionAttributes();
    sattr.setString(sattr.APPADDRESS, "//GVC3ZA03TESTING:3050");
    switch (sattr.checkAuthenticationLevel())
    case JoltSessionAttributes.NOAUTH:
    break;
    case JoltSessionAttributes.APPASSWORD:
    appPassword = "123456"//"appPassword";
    break;
    case JoltSessionAttributes.USRPASSWORD:
    userName = "myname";
    userPassword = "123456";
    appPassword = "123456";
    break;
    sattr.setInt(sattr.IDLETIMEOUT, 300);
    session = new JoltSession(sattr, userName, userRole,
    userPassword, appPassword);
    toupper = new JoltRemoteService ("TOUPPER", session);
    toupper.setString("STRING", "hello world");
    toupper.call(null);
    outstr = toupper.getStringDef("STRING", null);
    if (outstr != null)
    System.out.println(outstr);
    session.endSession();
    System.exit(0);
              }catch(Exception e){
              e.printStackTrace();
    } // end main
    } // end ToUpper

    Hi Todd,
    I am not getting the jcheckauthentication error now as i changed the port no. to the port where JSL is running.Now I am getting this error.Also find the ULOG contents pasted below.
    D:\bea\tuxedo9.1\samples\jolt\ToUpper>java ToUpper
    Authentication Level set To :0
    Exception caught error no is:6
    bea.jolt.ServiceException: TPENOENT - no entry found
    at bea.jolt.JoltRemoteService.decodeCALL(JoltRemoteService.java:460)
    at bea.jolt.JoltRemoteService.call(JoltRemoteService.java:345)
    at bea.jolt.JoltRemoteService.call(JoltRemoteService.java:267)
    at ToUpper.main(ToUpper.java:39)
    I have checked the jrepository file and also the Applet window for the service defination(TOUPPER)but still its not recognizing the service.Is there some configuration thing I have missed out before running JOLT client.
    ULOG File Contents
    132947.GVC3ZA03TESTING!JSH.4000.2464.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name ''; client name 'myapp'"
    132956.GVC3ZA03TESTING!WSL.432.5308.0: WSNAT_CAT:1196: INFO: Terminating handlers in preparation for shutdown
    132956.GVC3ZA03TESTING!WSL.432.5308.0: WSNAT_CAT:1197: INFO: Exiting system
    132956.GVC3ZA03TESTING!JSL.2644.2356.0: JOLT_CAT:1506: "INFO: Terminating Jolt administration services in preparation for shutdown"
    132956.GVC3ZA03TESTING!JSL.2644.2356.0: JOLT_CAT:1196: "INFO: Terminating handlers in preparation for shutdown"
    132956.GVC3ZA03TESTING!JSH.4000.2464.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name 'jolt'; client name 'joltadmin'"
    132956.GVC3ZA03TESTING!JSL.2644.2356.0: JOLT_CAT:1197: "INFO: Exiting system"
    132956.GVC3ZA03TESTING!DMADM.5844.5348.0: CMDGW_CAT:1655: INFO: DMADMSVR is exiting
    132959.GVC3ZA03TESTING!BBL.3216.4372.0: CMDTUX_CAT:26: INFO: The BBL is exiting system
    133021.GVC3ZA03TESTING!tmloadcf.6104.3164.-2: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133021.GVC3ZA03TESTING!tmloadcf.6104.3164.-2: CMDTUX_CAT:872: INFO: TUXCONFIG file D:\bea\tuxedo9.1\samples\jolt\ToUpper\tuxconfig has been updated
    133028.GVC3ZA03TESTING!BBL.6140.5124.0: 02-01-2007: Tuxedo Version 9.1, 32-bit, Patch Level (none)
    133028.GVC3ZA03TESTING!BBL.6140.5124.0: LIBTUX_CAT:262: INFO: Standard main starting
    133028.GVC3ZA03TESTING!DMADM.4928.1868.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133028.GVC3ZA03TESTING!DMADM.4928.1868.0: LIBTUX_CAT:262: INFO: Standard main starting
    133028.GVC3ZA03TESTING!DMADM.4928.1868.0: CMDGW_CAT:3149: INFO: BDMCONFIG environment variable not set. Using $APPDIR/BDMCONFIG
    133028.GVC3ZA03TESTING!DMADM.4928.1868.0: CMDGW_CAT:3761: INFO: Using version 2 BDMCONFIG, 3DES is enabled.
    133028.GVC3ZA03TESTING!JSL.5608.6088.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133028.GVC3ZA03TESTING!JSL.5608.6088.0: LIBTUX_CAT:262: INFO: Standard main starting
    133028.GVC3ZA03TESTING!JSL.5608.6088.0: INFO: JOLT Listener version-BEA Jolt 9.1
    133028.GVC3ZA03TESTING!JSL.5608.6088.0: JOLT_CAT:1563: "INFO: Serial Number : <454493271161-2140437240256>, Expiration Date : <2007-02-15>"
    133028.GVC3ZA03TESTING!JSL.5608.6088.0: JOLT_CAT:1564: "INFO: Licensee : <BEA Evaluation Customer>"
    133029.GVC3ZA03TESTING!JSH.6028.5748.-2: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133029.GVC3ZA03TESTING!JSH.6028.5748.-2: JOLT_CAT:1030: "INFO: Jolt Handler joining application"
    133029.GVC3ZA03TESTING!JSH.6028.5748.-2: INFO: JOLT Handler version-BEA Jolt 9.1
    133029.GVC3ZA03TESTING!JREPSVR.3476.4980.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133029.GVC3ZA03TESTING!JREPSVR.3476.4980.0: LIBTUX_CAT:262: INFO: Standard main starting
    133029.GVC3ZA03TESTING!JREPSVR.3476.4980.0: Current version: BEA Jolt 9.1
    133029.GVC3ZA03TESTING!JREPSVR.3476.4980.0: Repository "D:\bea\tuxedo9.1\udataobj\jolt\repository\jrepository" (16 records) is writable.
    133029.GVC3ZA03TESTING!WSL.3292.4892.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133029.GVC3ZA03TESTING!WSL.3292.4892.0: LIBTUX_CAT:262: INFO: Standard main starting
    133029.GVC3ZA03TESTING!WSH.2568.3772.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133029.GVC3ZA03TESTING!WSH.2568.3772.0: WSNAT_CAT:1030: INFO: Work Station Handler joining application
    133029.GVC3ZA03TESTING!WSH.5764.3836.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    133029.GVC3ZA03TESTING!WSH.5764.3836.0: WSNAT_CAT:1030: INFO: Work Station Handler joining application
    133242.GVC3ZA03TESTING!JSH.6028.5748.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"
    133300.GVC3ZA03TESTING!JSH.6028.5748.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name ''; client name 'myapp'"
    133300.GVC3ZA03TESTING!JSH.6028.5748.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"
    133359.GVC3ZA03TESTING!JSH.6028.5748.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name ''; client name 'myapp'"
    133456.GVC3ZA03TESTING!JSH.6028.5748.-2: Fldid32(ACCOUNT_ID) failed for INQUIRY: LIBFML_CAT:8: ERROR: Unknown field name. Maybe FIELDTBLS32 is not set properly.
    133612.GVC3ZA03TESTING!JSH.6028.5748.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"
    143325.GVC3ZA03TESTING!JSH.6028.5748.-2: Fldid(SAMOUNT) failed for DEPOSIT: LIBFML_CAT:11: ERROR: Cannot find or open field table. Maybe FIELDTBLS is not set properly.
    144116.GVC3ZA03TESTING!WSL.3292.4892.0: WSNAT_CAT:1196: INFO: Terminating handlers in preparation for shutdown
    144116.GVC3ZA03TESTING!WSL.3292.4892.0: WSNAT_CAT:1197: INFO: Exiting system
    144116.GVC3ZA03TESTING!JSL.5608.6088.0: JOLT_CAT:1506: "INFO: Terminating Jolt administration services in preparation for shutdown"
    144116.GVC3ZA03TESTING!JSL.5608.6088.0: JOLT_CAT:1196: "INFO: Terminating handlers in preparation for shutdown"
    144116.GVC3ZA03TESTING!JSH.6028.5748.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name 'jolt'; client name 'joltadmin'"
    144116.GVC3ZA03TESTING!JSL.5608.6088.0: JOLT_CAT:1197: "INFO: Exiting system"
    144116.GVC3ZA03TESTING!DMADM.4928.1868.0: CMDGW_CAT:1655: INFO: DMADMSVR is exiting
    144119.GVC3ZA03TESTING!BBL.6140.5124.0: CMDTUX_CAT:26: INFO: The BBL is exiting system
    144142.GVC3ZA03TESTING!tmloadcf.2668.3316.-2: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144142.GVC3ZA03TESTING!tmloadcf.2668.3316.-2: CMDTUX_CAT:872: INFO: TUXCONFIG file D:\bea\tuxedo9.1\samples\jolt\ToUpper\tuxconfig has been updated
    144148.GVC3ZA03TESTING!BBL.4144.4376.0: 02-01-2007: Tuxedo Version 9.1, 32-bit, Patch Level (none)
    144148.GVC3ZA03TESTING!BBL.4144.4376.0: LIBTUX_CAT:262: INFO: Standard main starting
    144148.GVC3ZA03TESTING!DMADM.4436.5968.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144148.GVC3ZA03TESTING!DMADM.4436.5968.0: LIBTUX_CAT:262: INFO: Standard main starting
    144148.GVC3ZA03TESTING!DMADM.4436.5968.0: CMDGW_CAT:3149: INFO: BDMCONFIG environment variable not set. Using $APPDIR/BDMCONFIG
    144148.GVC3ZA03TESTING!DMADM.4436.5968.0: CMDGW_CAT:3761: INFO: Using version 2 BDMCONFIG, 3DES is enabled.
    144148.GVC3ZA03TESTING!JSL.5072.2444.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144148.GVC3ZA03TESTING!JSL.5072.2444.0: LIBTUX_CAT:262: INFO: Standard main starting
    144148.GVC3ZA03TESTING!JSL.5072.2444.0: INFO: JOLT Listener version-BEA Jolt 9.1
    144148.GVC3ZA03TESTING!JSL.5072.2444.0: JOLT_CAT:1563: "INFO: Serial Number : <454493271161-2140437240256>, Expiration Date : <2007-02-15>"
    144148.GVC3ZA03TESTING!JSL.5072.2444.0: JOLT_CAT:1564: "INFO: Licensee : <BEA Evaluation Customer>"
    144148.GVC3ZA03TESTING!JSH.5856.5268.-2: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144148.GVC3ZA03TESTING!JSH.5856.5268.-2: JOLT_CAT:1030: "INFO: Jolt Handler joining application"
    144148.GVC3ZA03TESTING!JSH.5856.5268.-2: INFO: JOLT Handler version-BEA Jolt 9.1
    144148.GVC3ZA03TESTING!JREPSVR.2952.1248.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144148.GVC3ZA03TESTING!JREPSVR.2952.1248.0: LIBTUX_CAT:262: INFO: Standard main starting
    144148.GVC3ZA03TESTING!JREPSVR.2952.1248.0: Current version: BEA Jolt 9.1
    144148.GVC3ZA03TESTING!JREPSVR.2952.1248.0: Repository "D:\bea\tuxedo9.1\udataobj\jolt\repository\jrepository" (16 records) is writable.
    144148.GVC3ZA03TESTING!WSL.3040.5488.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144148.GVC3ZA03TESTING!WSL.3040.5488.0: LIBTUX_CAT:262: INFO: Standard main starting
    144148.GVC3ZA03TESTING!WSH.5740.2764.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144148.GVC3ZA03TESTING!WSH.5740.2764.0: WSNAT_CAT:1030: INFO: Work Station Handler joining application
    144148.GVC3ZA03TESTING!WSH.1784.5448.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144148.GVC3ZA03TESTING!WSH.1784.5448.0: WSNAT_CAT:1030: INFO: Work Station Handler joining application
    144157.GVC3ZA03TESTING!JSH.5856.5268.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"
    144207.GVC3ZA03TESTING!JSH.5856.5268.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name ''; client name 'myapp'"
    144226.GVC3ZA03TESTING!JSH.5856.5268.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"
    144229.GVC3ZA03TESTING!JSH.5856.5268.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"
    144518.GVC3ZA03TESTING!WSL.3040.5488.0: WSNAT_CAT:1196: INFO: Terminating handlers in preparation for shutdown
    144518.GVC3ZA03TESTING!WSL.3040.5488.0: WSNAT_CAT:1197: INFO: Exiting system
    144518.GVC3ZA03TESTING!JSL.5072.2444.0: JOLT_CAT:1506: "INFO: Terminating Jolt administration services in preparation for shutdown"
    144518.GVC3ZA03TESTING!JSL.5072.2444.0: JOLT_CAT:1196: "INFO: Terminating handlers in preparation for shutdown"
    144518.GVC3ZA03TESTING!JSH.5856.5268.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name 'jolt'; client name 'joltadmin'"
    144518.GVC3ZA03TESTING!JSL.5072.2444.0: JOLT_CAT:1197: "INFO: Exiting system"
    144519.GVC3ZA03TESTING!DMADM.4436.5968.0: CMDGW_CAT:1655: INFO: DMADMSVR is exiting
    144522.GVC3ZA03TESTING!BBL.4144.4376.0: CMDTUX_CAT:26: INFO: The BBL is exiting system
    144537.GVC3ZA03TESTING!tmloadcf.4892.4980.-2: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144537.GVC3ZA03TESTING!tmloadcf.4892.4980.-2: CMDTUX_CAT:872: INFO: TUXCONFIG file D:\bea\tuxedo9.1\samples\jolt\ToUpper\tuxconfig has been updated
    144543.GVC3ZA03TESTING!BBL.5440.4548.0: 02-01-2007: Tuxedo Version 9.1, 32-bit, Patch Level (none)
    144543.GVC3ZA03TESTING!BBL.5440.4548.0: LIBTUX_CAT:262: INFO: Standard main starting
    144543.GVC3ZA03TESTING!DMADM.1016.6128.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144543.GVC3ZA03TESTING!DMADM.1016.6128.0: LIBTUX_CAT:262: INFO: Standard main starting
    144543.GVC3ZA03TESTING!DMADM.1016.6128.0: CMDGW_CAT:3149: INFO: BDMCONFIG environment variable not set. Using $APPDIR/BDMCONFIG
    144543.GVC3ZA03TESTING!DMADM.1016.6128.0: CMDGW_CAT:3761: INFO: Using version 2 BDMCONFIG, 3DES is enabled.
    144543.GVC3ZA03TESTING!JSL.1796.5232.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144543.GVC3ZA03TESTING!JSL.1796.5232.0: LIBTUX_CAT:262: INFO: Standard main starting
    144543.GVC3ZA03TESTING!JSL.1796.5232.0: INFO: JOLT Listener version-BEA Jolt 9.1
    144543.GVC3ZA03TESTING!JSL.1796.5232.0: JOLT_CAT:1563: "INFO: Serial Number : <454493271161-2140437240256>, Expiration Date : <2007-02-15>"
    144543.GVC3ZA03TESTING!JSL.1796.5232.0: JOLT_CAT:1564: "INFO: Licensee : <BEA Evaluation Customer>"
    144543.GVC3ZA03TESTING!JSH.3164.4076.-2: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144543.GVC3ZA03TESTING!JSH.3164.4076.-2: JOLT_CAT:1030: "INFO: Jolt Handler joining application"
    144543.GVC3ZA03TESTING!JSH.3164.4076.-2: INFO: JOLT Handler version-BEA Jolt 9.1
    144543.GVC3ZA03TESTING!JREPSVR.860.2916.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144543.GVC3ZA03TESTING!JREPSVR.860.2916.0: LIBTUX_CAT:262: INFO: Standard main starting
    144543.GVC3ZA03TESTING!JREPSVR.860.2916.0: Current version: BEA Jolt 9.1
    144543.GVC3ZA03TESTING!JREPSVR.860.2916.0: Repository "D:\bea\tuxedo9.1\udataobj\jolt\repository\jrepository" (16 records) is writable.
    144543.GVC3ZA03TESTING!WSL.2596.4404.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144543.GVC3ZA03TESTING!WSL.2596.4404.0: LIBTUX_CAT:262: INFO: Standard main starting
    144543.GVC3ZA03TESTING!WSH.3508.5136.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144543.GVC3ZA03TESTING!WSH.3508.5136.0: WSNAT_CAT:1030: INFO: Work Station Handler joining application
    144543.GVC3ZA03TESTING!WSH.4288.5676.0: 02-01-2007: Tuxedo Version 9.1, 32-bit
    144543.GVC3ZA03TESTING!WSH.4288.5676.0: WSNAT_CAT:1030: INFO: Work Station Handler joining application
    144548.GVC3ZA03TESTING!JSH.3164.4076.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"
    144634.GVC3ZA03TESTING!JSH.3164.4076.-2: JOLT_CAT:1198: "WARN: Forced shutdown of client; user name ''; client name 'myapp'"
    144734.GVC3ZA03TESTING!JSH.3164.4076.-2: JOLT_CAT:1043: "ERROR: tpacall() call failed, tperrno = 6"

  • Async tcp client and server. How can I determine that the client or the server is no longer available?

    Hello. I would like to write async tcp client and server. I wrote this code but a have a problem, when I call the disconnect method on client or stop method on server. I can't identify that the client or the server is no longer connected.
    I thought I will get an exception if the client or the server is not available but this is not happening.
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    How can I determine that the client or the server is no longer available?
    Server
    public class Server
    private readonly Dictionary<IPEndPoint, TcpClient> clients = new Dictionary<IPEndPoint, TcpClient>();
    private readonly List<CancellationTokenSource> cancellationTokens = new List<CancellationTokenSource>();
    private TcpListener tcpListener;
    private bool isStarted;
    public event Action<string> NewMessage;
    public async Task Start(int port)
    this.tcpListener = TcpListener.Create(port);
    this.tcpListener.Start();
    this.isStarted = true;
    while (this.isStarted)
    var tcpClient = await this.tcpListener.AcceptTcpClientAsync();
    var cts = new CancellationTokenSource();
    this.cancellationTokens.Add(cts);
    await Task.Factory.StartNew(() => this.Process(cts.Token, tcpClient), cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
    public void Stop()
    this.isStarted = false;
    foreach (var cancellationTokenSource in this.cancellationTokens)
    cancellationTokenSource.Cancel();
    foreach (var tcpClient in this.clients.Values)
    tcpClient.GetStream().Close();
    tcpClient.Close();
    this.clients.Clear();
    public async Task SendMessage(string message, IPEndPoint endPoint)
    try
    var tcpClient = this.clients[endPoint];
    await this.Send(tcpClient.GetStream(), Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async Task Process(CancellationToken cancellationToken, TcpClient tcpClient)
    try
    var stream = tcpClient.GetStream();
    this.clients.Add((IPEndPoint)tcpClient.Client.RemoteEndPoint, tcpClient);
    while (!cancellationToken.IsCancellationRequested)
    var data = await this.Receive(stream);
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(NetworkStream stream, byte[] buf)
    await stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive(NetworkStream stream)
    var lengthBytes = new byte[4];
    await stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await stream.ReadAsync(buf, 0, buf.Length);
    return buf;
    Client
    public class Client
    private TcpClient tcpClient;
    private NetworkStream stream;
    public event Action<string> NewMessage;
    public async void Connect(string host, int port)
    try
    this.tcpClient = new TcpClient();
    await this.tcpClient.ConnectAsync(host, port);
    this.stream = this.tcpClient.GetStream();
    this.Process();
    catch (Exception exception)
    public void Disconnect()
    try
    this.stream.Close();
    this.tcpClient.Close();
    catch (Exception exception)
    public async void SendMessage(string message)
    try
    await this.Send(Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(byte[] buf)
    await this.stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await this.stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive()
    var lengthBytes = new byte[4];
    await this.stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await this.stream.ReadAsync(buf, 0, buf.Length);
    return buf;

    Hi,
    Have you debug these two applications? Does it go into the catch exception block when you close the client or the server?
    According to my test, it will throw an exception when the client or the server is closed, just log the exception message in the catch block and then you'll get it:
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.Invoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    Console.WriteLine(exception.Message);
    Unable to read data from the transport connection: An existing   connection was forcibly closed by the remote host.
    By the way, I don't know what the SafeInvoke method is, it may be an extension method, right? I used Invoke instead to test it.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to create client and server app using node.js in firefox os.

    I want to create a client and server app using node.js for firefox os. Please suggest me how to create a apps.
    I want to send a request from client to server and based on client request, service reply to client.
    If any links available, Please share it.
    Thanks

    Hi sb00349044,
    The SUMO forums focuses on end-user support.
    For questions about developing for Firefox OS, you will find better guidance in MDN, StackOverflow, and mailing lists:
    * [https://developer.mozilla.org/en-US/Firefox_OS MDN - Firefox OS]
    * [http://stackoverflow.com/questions/tagged/firefox-os StackOverflow - Firefox OS]
    * [https://lists.mozilla.org/listinfo Mailing Lists at Mozilla]
    Thanks,
    - Ralph

  • How to run a block from client avoiding timeout

    Hi,
    I have a block to run on my pc which will then communicate with the server and then complete the process and get the results. Now if my network connection dies in mean time, then the job gets terminated halfway. PLEASE let me know if anyone know how to run a job directly on the server or somekind of workaround to run it unexhaustively. just like we have NOHUP facility for UNIX scripts, do we have something for oracle.
    Would be eager to get some solution.
    Thanks and Regards.

    You don't need the DBA role, no. You would need EXECUTE access on the DBMS_JOB or DBMS_SCHEDULER package, which you may well already have. Note that the DBMS_SCHEDULER package is only available in 10g-- you didn't specify what version of Oracle you're using, so I'm not sure if that's an option for you.
    The simplest possible solution would be something like
    DECLARE
      l_jobno NUMBER;
    BEGIN
      dbms_job.submit( l_jobno,  <<SQL script>>, sysdate + interval '1' minute );
      commit;
    END;which would run the <<SQL script>> in a background session starting in 1 minute.
    Justin

  • How corba client and server find Naming service

    hello
    i want to ask how corba client and server find the Naming service ?
    10x

    By using a well-known port (I think the default for JavaIDL's NS is 1049) on a well-known address (localhost).
    As these values are not really standard, you can specify them when starting the server and client (+-ORBInitialPort 1050 -ORBInitialHost localhost+). See the documentation .

  • JSSE  Client and server communication problem .err:untrusted server cert

    Hai all,
    I am trying to communicate JSSE client and server.
    I have created root.cert(CA),root.key,server.cert,server.key , client.cert and client.key. All these certificates are created using openssl.
    I have placed root.cert in default keystore cacerts.
    I have created a keystores(server & client) name mykeystore.
    I have placed root.cert and client.cert in the client keystore.
    I have placed root.cert and server.cert in the server keystore.
    But during the run time i am getting javax.net.ssl.SSLException: untrusted server cert chain.
    please suggest the modifications needs to be done to fix the error.
    please tell me In the client keystore and in the server keystore....what certificates we need to put?
    whether my approach as said above is correct or not?
    In java code how to specify this particular certificate we are referring?
    I have coded in this way ....
    SSLContext ctx;
    KeyManagerFactory kmf;
    KeyStore ks;
    char[] prasad = "prasad".toCharArray();
    ctx = SSLContext.getInstance("SSLv3");
    kmf = KeyManagerFactory.getInstance("SunX509");
    ks = KeyStore.getInstance("jks");
    ks.load(new FileInputStream("mykeystore"), prasad);
    kmf.init(ks, prasad);
    ctx.init(kmf.getKeyManagers(), null, null);
    factory = ctx.getSocketFactory();
    But my doubt is we are specifying only keystore name with that how it will check root.cert(ca) and client.cert and server.cert?
    Is there any modifications need in my code?
    Please tell me some way ...
    Thanks ,
    Prasad.

    Hi prasad,
    There will be a problem with the certificates being received from thr remote server or client. Check that your trust store contains the certificate of the remote machine or the CA that signed it and that the certificate has not expired.
    Also be sure that both machines are using the latest version of the JSSE.
    Hope this will help you.
    Regards,
    Anil.
    Technical Support Engineer.

  • UDP Client and Server

    I am trying to run a UDP Client and Server by running the server first and then the client. But when I try to do that I get the message java.lang.NoClassDefFoundError: UDPServer and java.lang.NoClassDefFoundError: UDPClient. I have included the code below. Can you please help. Thank you.
    UDPClient.java:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class UDPClient{
        public static void main(String[] args) throws IOException{
          Date d=new Date();
          long time1, time2, ETE, sumETE, maxETE, avgETE;
          if(args.length!=1){
              System.out.println("type java UDPClient <hostname>");
              return;
          time1=d.getTime();
          DatagramSocket s=new DatagramSocket();
          String st=new String("dldfjsdkjf");
          byte[] buf=new byte[256];
          buf=st.getBytes();
          InetAddress address=InetAddress.getByName(args[0]);
          DatagramPacket p = new DatagramPacket(buf, buf.length, address, 8777);
          s.send(p);
          p=new DatagramPacket(buf, buf.length, address, 8777);
          s.receive(p);
          time2=d.getTime();
          ETE=(time2-time1)/2;
          s.close();
    UDPServer.java:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.lang.*;
    public class UDPServer{
      public static void main(String[] args){
        try{
          UDPServerThread ust = new UDPServerThread();
          ust.start();
        catch(IOException e){}
    UDPServerThread.java:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.lang.*;
    public class UDPServerThread extends Thread{
      DatagramSocket s=null;
      BufferedReader br=null;
      PrintWriter pw=null;
      public UDPServerThread() throws IOException{
        this("UDPServer");
      public UDPServerThread(String name) throws IOException{
        super(name);
        s=new DatagramSocket(8777);
      public void run(){
          char[] ca=new char[10];
        //while(true){
          try{
              byte[] buf = new byte[256];
              DatagramPacket p = new DatagramPacket(buf, buf.length);
              s.receive(p);
              String st=new String(p.getData());
              for(int i=0; i<10; i++){
                  ca=st.charAt(i);
    buf=st.getBytes();
    InetAddress ad = p.getAddress();
    int port = p.getPort();
    p = new DatagramPacket(buf, buf.length, ad, port);
    s.send(p);
    catch(IOException e){
    System.err.println("Failed to run the server");
    System.exit(-1);
    s.close();

    this has nothing to do with your code, but how you are running it. It is a classpath problem.
    You should go to the directory where the UDPClient.class is, and type
    java -classpath . UDPClient
    similarly for the UDPServer

  • Strange problem with SQLPLUS when client and server on the same box

    Hi,
    I have the problem with SQLPLUS when clinet and server on the same machine.
    With client and server on the same machine i am running the command
    sqlplus -l username/password@connect_identifier as SYSDBA.
    With this command, even if you pass in wrong username or wrong password or both as wrong you can able to connect to database and execute queries.
    Once Connect_identifier is correct and trying to log in as SYSDBA ,sqlplus will log in to DB with any username and password.
    How to get rid of this behaviour. Is there any way to do this.
    I am running this command by creating a process in C#
    Edited by: user11000236 on Jun 16, 2009 10:31 AM

    user11000236 wrote:
    Thanks for the info.
    How does Oracle/SQLPLUS allows any username or password to log in to DB with SYSDBA Privillages? What is the concept behind this.?
    This is explainted in the above mentioned link:
    Operating system authentication takes precedence over password file authentication. If you meet the requirements for operating system authentication, then even if you use a password file, you will be authenticated by operating system authentication.

  • Client and Server in one process

    Hi all,
    I am trying to create a process which can act as both Client and Server.
    How can I do this?
    Thanks!

    AH. That's a better definition or explanation. Thanks.
    This smells of a single process with multiple threads, each thread handling the basic needs of your requirements. In other words, have a thread deal with making one or more client type connections (use a main thread - the client controller - to spawn client-connection threads. This assumes you need multiplicity in your client-connection model.
    Then make another thread - the server controller - to handle inbound connections, spawning a new thread for each inbound connection. Your main thread, the one that contains your main method, can watch everything that's going on and log or report what's going on in your client and server threads.
    Going into specifics would be a lot to do here. Maybe someone is up for the challenge. Of course, this being a "New to Java Technology" forum, these concepts may be a bit beyond your skillset.
    This is not the only way to go about solving your problem, but it's the only way I can think of at the moment given your requirements.
    Hope this helps some.

  • Communication between client and server

    I am using sockets for communication between the client and the server. is there any other way that i can use for communication between the client and server???

    Plenty of ways: JMS, SOAP, RMI, a RESTful API, writing-files-to-a-shared-directory-on-the-disk, Sneakernet, ...
    Some of them use sockets (or better TCP/IP) as the underlying protocol.
    But to give you a good answer, you would have to tell us why you want a different way. I hope you're not searching for a different way just for the sake of being different.

  • How to run ear file in java application server

    i want how to run .ear file in java application server
    1. i m created ear file
    2. i m created jar file (bean,home,remote)
    3.i m created war file(in the form of jsp)
    but till now i couldnt run ear file
    how to run
    please hel me

    You must create :
    1.Jar file
    2.War file
    And then put them into an ear file
    Exemple : myapp.ear contains
    myappEJB.jar
    myappWEB.war
    META-INF/application.xml
    and application.xml looks like this :
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
        <display-name>myapp</display-name>
        <description>Demo application</description>
        <module>
            <ejb>myappEJB.jar</ejb>
        </module>
        <module>
          <web>
             <web-uri>myappWAR.war</web-uri>
             <context-root>/myapp</context-root>
          </web>
        </module>
    </application>Good luck

Maybe you are looking for

  • TS1424 Have you ever been charged repeatedly and indefinitely for a single album?

    I recently bought the album "The Best Celtic Worship Album in the World Ever" and i got 50 copies and charged my bank account.

  • Incrementing a variable in memory

    I have an older application that is querying a list, pulling out an AD from the list, then incrementing the database by +1 with every pull. The site has grown very popular and now the traffic is creating a ton of deadlocks. I tried using CFLOCK but t

  • Parametrizing a Base Class

    Lets say you have a subclass A and superclass B. The base class contains most of the methods that use the type E. So I need to parametrize both A and B. How do I parametrize B with the same thing that I parametrize A?

  • Nested sites in site manager

    I tried to see if I could have nested sites in the site manager and it looks like that works. c:/www/site1/webroot < ------ (root for first site, inner site) c:/www/site1 <--------------------(root for second site, outer site) (I will need this to wo

  • Our business would like to use or connect to an other online payment gateway on Business Catalyst.

    Dear Manger, Our business would like to use or connect to an other online payment gateway on Business Catalyst, That's the KCP (www.KCP.co.kr) serviced  in South Korea. We have registered already at KCP. Can we use or connect the payment gateway serv