Reliable UDP client/server sample

I need a reliable UDP client/server sample which uses ack,timeout,sequence number, etc. Client and server are different computers in the same network and I need to send a file >10Mb. Where can I find this kind of example? It is required for a project at my university.
Thanks.

Can't you use TCP? It already is reliable, has better performance than simple UDP+ACKs (unless you too implement sliding windows), and is a good network citizen (unless you too implement congestion control). Why reinvent the wheel?
Unless of course your assignment is "reimplement TCP using UDP" in which case you can find the "example" by writing it.

Similar Messages

  • TCP client server sample

    All,
    This may not really be a LabWindows/CVI question but I'm really stuck on what should be easy to
    solve. The brain trust here on the forums has always been helpful so I'll try to explain.
    The project:
    Get LabWindows/CVI code talking to a muRata SN8200 embedded WiFi module.
    The setup:
    (running Labwindows/CVI 2009)
    Computer 1 -- (with a wireless NiC) running simple demo TCP server program provided by muRata.
    Computer 2 -- USB connection (virtual COM port) with simple program (also provided by muRata) that talks to the SN8200 embedded WiFi module.  This code along with the module creates a simple TCP client.
    Whats working:
    I can successfuly get the Computer 2 client connected to and talking to the Computer 1 server. (using the muRata supplied code)
    I can also run the LabWindows/CVI sample code from (\CVI2009\samples\tcp), server on computer 1 & client on computer 2 and they talk with no problems.
    (I'm using the same IP addresses and port numbers in all cases)
    Whats NOT working:
    Run the CVI server program on computer 1.
    I cannot get the muRata client program  to connect to the CVI server.
    I also tried get the CVI client program to connect to the muRata server.  No luck that way either. The CVI client sample program trys connect, and this function call:
    ConnectToTCPServer (&g_hconversation, portNum, tempBuf, ClientTCPCB, NULL, 5000 );
    returns with a timeout error code (-11).
    What I need:
    Some ideas on how to get this working.
    Is there something unique about the LabWindows/CVI sample client/server demo code that would make them incompatible with the muRata code?
    Can you think of some ways I can debug this further?  I feel like I'm kind of running blind.
    What else can I look at?
    For those that have read this far, thanks much and any ideas or comments will be appreciated,
    Kirk

    Humphrey,
    First,
    I just figured out what the problem is:
    When I was trying to use the CVI sample server I was entering the wrong port number.
    The reason I entered the wrong port was because the hard-coded port number in the muRata demo code was displayed in hex as 0x9069. ( I converted this to decimal and entered it into the CVI sample server code) The correct port number was 0x6990.  (upper and lower bytes swapped)  Arrgh!
    I found the problem by using the netstat command line utility to display the connections and noted that the port being used was not 0x9069.  It is really a problem with the muRata eval kit demo code.
    Second,
    Humphrey you are right about the CVI sample code not handling all the muRata commands for the client end of the connection that communicates with the SN8200 module.  For my test I was using the muRata code for that "end".
    The server end is simple and the CVI sample is adequate and is now working.
    Thank you to all who took the time to browse my questions,
    Kirk

  • UDP client/server

    Im trying to connect to a server from my client useing UDP. My partner has the server but im not able to see it at the moment. I have the client that is trying to reach it. Here is the code i use:public Connect(String serv_addr){
              try{
                   skt = new DatagramSocket();
                   server = InetAddress.getByName(serv_addr);
                   byte[] connectData = new byte[128];
                   connectData = sentance.getBytes();
                   sendPacket = new DatagramPacket(connectData, connectData.length,
                             server, 4525);
                   skt.send(sendPacket);
                   System.out.println(new String(sendPacket.getData()));
              catch(IOException e){
                   System.err.println(e);
         }When i run it, i cannot connect and my partner tells me the server is running. Without seeing the Server code and assuming it works properly, does my code look right? The last line in the try statment, Syste.out.ptintln is justing being used for testing.
    Thanks in advance

    and is there a firewall in the way? If so it won't probably won't forward UDP traffic on that port unless it's been told to, and you won't get an exception.
    And some possibly silly questions:
    a. are you sure it's a UDP server?
    b. are you aware that UDP is an unreliable transport?
    You could also try to connect() the datagram socket to that target address before you send. That way if the target is unreachable you will at least get an exception.

  • UDP Client-Server Communication

    What should I do to the following code to make it able to create a sequence of packets of pre-specified length and size? Also, by varying these parameters, it should be able to create the situation where the packets are lost due to congestion.
    import java.net.*;
    import java.io.*;
    public class UDPServer{
        public static void main(String args[]){
           System.out.println("### Starting UDPServer...");
           DatagramSocket aSocket = null;
                  try{
                  aSocket = new DatagramSocket(6789);
                                      // create socket at agreed port
                         byte[] buffer = new byte[1000];
                         while(true){
                               DatagramPacket request = new DatagramPacket(buffer, buffer.length);
                               aSocket.receive(request);    
                         DatagramPacket reply = new DatagramPacket(request.getData(), request.getLength(),
                               request.getAddress(), request.getPort());
                         System.out.println("sending reply = " + new String(reply.getData()));
                         aSocket.send(reply);
                  }catch (SocketException e){System.out.println("Socket: " + e.getMessage());
                  }catch (IOException e) {System.out.println("IO: " + e.getMessage());
                  }finally {if(aSocket != null) aSocket.close();}
    import java.net.*;
    import java.io.*;
    public class UDPClient
        public static void main(String args[])
                  System.out.println("=== Starting UDPClient...");              ///////
                  // args give message contents and destination hostname
                  DatagramSocket aSocket = null;
                  try {
                         aSocket = new DatagramSocket();   
                         byte [] m = args[0].getBytes();
                         InetAddress aHost = InetAddress.getByName(args[1]);
                         int serverPort = 6789;                                                            
                         DatagramPacket request =
                                new DatagramPacket(m,  args[0].length(), aHost, serverPort);
                         System.out.println("sending request = " + new String(request.getData()));
                         aSocket.send(request);                                          
                         byte[] buffer = new byte[1000];
                         DatagramPacket reply = new DatagramPacket(buffer, buffer.length);   
                         aSocket.receive(reply);
                         System.out.println("Got reply: " + new String(reply.getData()));    
                  } catch (SocketException e) {
                         System.out.println("Socket: " + e.getMessage());
                  } catch (IOException e) { System.out.println("IO: " + e.getMessage());
                  } finally { if(aSocket != null) aSocket.close(); }
    }

    DatagramPacket.

  • Can i run UDP  client and UDP  server socket program in the same pc ?

    hi all.
    when i execute my UDP client socket program and UDP server socket program in the same pc ,
    It's will shown the error msg :
    "Address already in use: Cannot bind"
    but if i run UDP client socket program in the remote pc and UDP server socket program run in local pc , it's will success.
    anybody know what's going on ?
    any help will be appreciated !

    bobby92 wrote:
    i have use a specified port for UDP server side , and for client define the server port "DatagramSocket clientSocket= new DatagramSocket(Server_PORT);"Why? The port you provide here is not the target port. It's the local port you listen on. That's only necessary when you want other hosts to connect to you (i.e. when you're acting as a server).
    The server should be using that constructor, the client should not be specifying a port.
    so when i start the udp server code to listen in local pc , then when i start UDP client code in local pc ,i will get the error "Address already in use: Cannot bind"Because your client tries to bind to the same port that the server already bound to.

  • 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

  • Client/Server in one program (using multiple threads)?

    Is there some examples out there of how to use a client and server in a single program using separate threads? Also, is it possible to start a third thread to control the packets, such as drop a random or specified number of packets (or match on specific data in a packet)?

    Just trying to have a client send udp packets to a server (all on the same machine running from the same program) and want to be able to drop packets coming from the client side to the server side.
    E.g.,
    Here's an example that I found here: http://compnet.epfl.ch/tps/tp5.html
    import java.io.<strong>;
    import java.net.</strong>;
    import java.util.<strong>;
    /</strong>
    * Server to process ping requests over UDP.
    public class PingServer {
         private static double lossRate = 0.3;
         private static int averageDelay = 100; // milliseconds
         private static int port;
         private static DatagramSocket socket;
         public static void main(String[] args) {
              // Get command line arguments.
              try {
                   if (args.length == 0) {
                        throw new Exception("Mandatory parameter missing");
                   port = Integer.parseInt(args[0]);
                   if (args.length > 1) {
                        lossRate = Double.parseDouble(args[1]);
                   if (args.length > 2) {
                        averageDelay = Integer.parseInt(args[2]);
              } catch (Exception e) {
                   System.out.println("UDP Ping Server");
                   System.out.println("Usage: java PingServer port [loss rate] [average delay in miliseconds]");
                   return;
              // Create random number generator for use in simulating
              // packet loss and network delay.
              Random random = new Random();
              // Create a datagram socket for receiving and sending UDP packets
              // through the port specified on the command line.
              try {
                   socket = new DatagramSocket(port);
                   System.out.println("UDP PingSever awaiting echo requests");
              } catch (SocketException e) {
                   System.out.println("Failed to create a socket");
                   System.out.println(e);
                   return;
              // Processing loop.
              while (true) {
                   // Create a datagram packet to hold incoming UDP packet.
                   DatagramPacket request = new DatagramPacket(new byte[1024], 1024);
                   // Block until the host receives a UDP packet.
                   try {
                        socket.receive(request);
                   } catch (IOException e) {
                        System.out.println("Error receiving from socket");
                        System.out.println(e);
                        break;
                   // Print the received data.
                   printData(request);
                   // Decide whether to reply, or simulate packet loss.
                   if (random.nextDouble() < lossRate) {
                        System.out.println("   Reply not sent.");
                        continue;
                   // Simulate network delay.
                   try {
                        Thread.sleep((int) (random.nextDouble() * 2 * averageDelay));
                   } catch (InterruptedException e) {}; // Ignore early awakenings.
                   // Send reply.
                   InetAddress clientHost = request.getAddress();
                   int clientPort = request.getPort();
                   byte[] buf = request.getData();
                   DatagramPacket reply = new DatagramPacket(buf, buf.length,
                             clientHost, clientPort);
                   try {
                        socket.send(reply);
                   } catch (IOException e) {
                        System.out.println("Error sending to a socket");
                        System.out.println(e);
                        break;
                   System.out.println("   Reply sent.");
          * Print ping data to the standard output stream.
         private static void printData(DatagramPacket request) {
              // Obtain references to the packet's array of bytes.
              byte[] buf = request.getData();
              // Wrap the bytes in a byte array input stream,
              // so that you can read the data as a stream of bytes.
              ByteArrayInputStream bais = new ByteArrayInputStream(buf);
              // Wrap the byte array output stream in an input stream reader,
              // so you can read the data as a stream of characters.
              InputStreamReader isr = new InputStreamReader(bais);
              // Wrap the input stream reader in a buffered reader,
              // so you can read the character data a line at a time.
              // (A line is a sequence of chars terminated by any combination of \r
              // and \n.)
              BufferedReader br = new BufferedReader(isr);
              // We will display the first line of the data.
              String line = "";
              try {
                   line = br.readLine();
              } catch (IOException e) {
              // Print host address and data received from it.
              System.out.println("Received echo request from "
                        + request.getAddress().getHostAddress() + ": " + line);
    }I'm looking to do the "processing loop" in a separate thread, but I'd also like to do the client in a separate thread
    So you're saying, just put the client code in a separate class and start the thread and that's it? As far as the packet rate loss thread, is this possible to do in another thread?

  • Best practice for client-server(Socket) application

    I want to build a client-server application
    1) On startup.. client creates connection to Server and keeps reading data from server
    2) Server keeps on sending different messages
    3) Based on messages(Async) from server client view has to be changed
    I tried different cases ended up facing IllegalStateChangeException while updating GUI
    So what is the best way to do this?
    Please give a working example .
    Thanks,
    Vijay
    Edited by: 844427 on Jan 12, 2012 12:15 AM
    Edited by: 844427 on Jan 12, 2012 12:16 AM

    Hi EJP,
    Thanks for the suggestion ,
    Here is sample code :
    public class Lobby implements LobbyModelsChangeListener{
        Stage stage;
        ListView<String> listView;
        ObservableList ol;
         public Lobby(Stage primaryStage) {
            stage = primaryStage;
               ProxyServer.startReadFromServer();//Connects to Socket Server
             ProxyServer.addLobbyModelChangeListener(this);//So that any data from server is fetched to Lobby
            init();
        private void init() {
              ProxyServer.getLobbyList();//Send
            ol = FXCollections.observableArrayList(
              "Loading Data..."
            ol.addListener(new ListChangeListener(){
                @Override
                public void onChanged(Change change) {
                    listView.setItems(ol);
         Group root = new Group();
        stage.setScene(new Scene(root));
         listView = new ListView<String>();
        listView.maxWidth(stage.getWidth());
         listView.setItems(ol);
         listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        istView.setOnMouseClicked(new EventHandler<MouseEvent>(){
                @Override
                public void handle(MouseEvent t) {
    //                ListView lv = (ListView) t.getSource();
                    new NewPage(stage);
         root.getChildren().add(listView);
         @Override
        public void updateLobby(LobbyListModel[] changes) {
    //        listView.getItems().clear();
            String[] ar = new String[changes.length];
            for(int i=0;i<changes.length;i++)
                if(changes!=null)
    System.out.println(changes[i].getName());
    ar[i] = changes[i].getName();
    ol.addAll(ar);
    ProxyServer.javaProxyServer
    //Implements runnable
    public void run()
         ......//code to read data from server
    //make array of LobbyListModel[] ltm based on data from server
         fireLobbyModelChangeEvent(ltm);
    void addLobbyModelChangeListener(LobbyModelsChangeListener aThis) {
    this.lobbyModelsChangeListener = aThis;
         private void fireLobbyModelChangeEvent(LobbyListModel[] changes) {
    LobbyModelsChangeListener listner
    = (LobbyModelsChangeListener) lobbyModelsChangeListener;
    listner.updateLobby(changes);
    Exception :
    java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-5
             at line         ol.addAll(ar);
    But ListView is getting updated with new data...so not sure if its right way to proceed...
    Thanks,
    Vijay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 10.5 server: could not reliably determine the server´s fully qualified doma

    I bought mac 10.5 server unlimited clientes, yesterday I tried to install the software 3 times and never worked (from basic to advanced apple preconfigurations). I had the carrier support yesterday to verify that it is not a problem of the link.
    the server has static IP, manually asigned.
    server admin: computer name www.MMM.com, local hostname: www, network interface: ethernet (0), ipv4, add 201.122.etc.etc) dns name: dsl-201-122-63.etc !here LEOPARD is taking the address from the DSLÑ provider,!!!!! and I dont know how to change, but the address is entered manually in the network preferences!!!!!.
    I go to admin server: server name: www.MMM.com, services: DNS and WEB : ON
    DNS: Zones; www.MMM.com, type: primary
    Homepage: Service: www.MMM:com:80
    (also, I tri8ed with A redord www, type machine, value: 201.122.etc.etc)
    WEB: enabled domain name www.MMM.com address (any or 201.122.etc.etc), port 80,webserver
    alias: MMM.com, web services enabled: all.
    also enabled default address any, port 80
    stop, and start web service.
    error log:
    httpd: aprsockaddr_infoget() failed afor www.MMM.com
    httpd: could not reliably determine the server´s fully qualified domain name, using 127.0.0.1 for server name..
    any idea about how to correct that? I tried also the new installation, formating the disk, and the server software is not configurating the server correctly)the easy and advances installation are not working correctly).
    thanks a lot
    Alberto

    ok,
    I formated the MAC server for 4th time, installed again the server software, then I went for the Basic configuration. then entered the adress manually, then you have to delete the DNS entry (set it in blank), then in the next window enter the NS (which is the server name). then continue the installation.
    after starting the web service is running and it is resolving address.then you can upgrade to the advanced configuration and install the other services.
    in that order the www is resolving the address.

  • JavaFX as a SaaS/ How good is it for Client-Server work?

    I was under the impression that FX could be used to produce a Client-Server application as well as SaaS.
    a member of another forum said "I'm sure you meant to say "Desktop". JavaFX will not be making inroads on the web as a client-side technology."
    To which I said
    There have been examples of FX used with EE
    http://www.oracle.com/technetwork/java/javafx/samples/index.html
    http://docs.oracle.com/javafx/2/overview/jfxpub-overview.htm
    Sales Dashboard (DataApp)
    DataApp is a client-server application for a fictional global automobile company called Henley Car Sales. Automobile sales are simulated on an EJB server using JavaDB, and the data is available via Derby and a RESTful web service. The client demonstrates a variety of data presentations by using a mix of FXML and JavaFX.
    I thought originally that JavaFX was "Desktop" only also, until I found this example. I couldn't get it to run due to some weird Database line read issue that others also had. I'm not sure if this is now due to FX's integration, or if this was something new, but I believe I have seen another FX client-server app as well.
    I'm not that familiar with the client-server side of Java yet, so if you have other Information I would like to know, because I am looking to design a Client-Server app with FX, and I don't see why it would be an issue, unless there are huge limitations."
    He ended up saying "Those are still desktop apps. Sure, they are client-server in that they connect to a remote database. But they are still traditional fat-client apps rather than web-based thin-client SAAS web applications which, these days, most people will think of when you say "client".
    My point is to be more precise when you use the word "client".
    But if your point is just that JavaFX is taking over from Swing for the limited areas in which Swing is used, I have no insight into that area."
    Now I don't really like attitudes when I get my question answered, but the high and mighty needs to stop. It clearly says Client-Server so I don't know why it's being denounced by this dude who thinks he obviously knows better.
    Anyways he talks about it only being able to connect to a DB, to which it says it uses EE tech such as EBJ, Restful, and Derby, so that's more than just DB right(I don't know since I havent' learned that yet)?
    It seems as if he's saying that only EE code can go up on a server? Or can SE code go up there as well?
    I'm looking to design a SaaS software with FX, so if this isnt' possible I would like to know possible other options(or just having all of the gui work on the client, and the rest on the backend)???
    Thanks!
    ~KZ
    Edited by: KonradZuse on Apr 30, 2013 11:26 AM

    This response is not a tutorial, I hope it gives you some verbiage to use in further searches.
    SaaS to me means that the service is running on the server. If you have the server and permission to run java apps there then you can use Java FX by having the server shuttle requests to the Java FX app. But this is probably not the intent of Saas (it would be more appropriate to use a java implemented web service).
    If you are using Netbeans then it is very easy to create demo projects; use "File/New Project" to run them on your local computer.
    Example File/New Project/Java Web/Web Application will give you a hello world web site very quickly. This will 1) start either tomcat or glassfish as the server. 2) launch an html page with "hello world". then you can use java script to talk with the server via ajax. Using this approach you are going to need to study JSP or J2EE stuff.
    After this is running you could start one of the Java Fx examples in Netbeans: File / New Project / Samples / WebViewBrowser. This will start a javaFX app that acts like a browser and runs on the client.
    So, start the "hello world" app in netbeans by right clicking it in the project pain and selecting "debug". Then start the webviewBrowser app the same way to load that web page that has "hello world" in it as all browsers do. In the WebviewBrowser (which is java fx) you can get at the javascript in the web page and do all kinds of stuff. You'll need to search for webviewBrowser examples.
    The above all assumes a Netbeans solution. But, as you probably know, there are no rules. The server can be in C++ and the client in C (or any other language). The server and client usally communicate via http or tcp. So you could have a server written in java (maybe J2ee or you can rewrite a http server from scratch which isn't that hard - search for "HttpServletRequest and HttpSession" ) and the client can be in Java FX (where the Java FX talks directly with the server via http (no javascript or web page in the middle) again there are probably hundreds of libraries to talk to a http server).
    I use HttpServletRequest and HttpSession on the server side with MySQL and xml. On the client I use javaScript but I am moving to a strictly Java FX solution. This will give me close to 100% java on both sides and for my purposes this will work. (I may need a little html in the middle for drag and drop installation.) I am hoping that work continues with porting Java FX to most devices: Android, IOS, WinPhone. It is already on Linux, Windows Desktops and Mac.
    Edited by: KevinPas on May 1, 2013 9:50 AM
    Edited by: KevinPas on May 1, 2013 9:56 AM

  • Client/Server API with push?

    I set up a simple Socket client server architecture with the Java socket API. However, my clients sometimes are initiators or requests, and sometimes my server is the initiator of infos. Example: client want to get infos from server but also want to tell the server something. The server tells all registered clients something but also can accept requests from clients. So both sides are client AND server (depending on what they currently want to do).
    The socket API is just a classic client/server API, i.e. a server listens and a client sends requets and get responses. For my server to send requests to all clients, this is not enough. Is the only way to have all clients offering a socket server on their computer, too? so that this 2-way-request-communication works?
    This is basically some kind of "push" technology, but i don't want my clients to "poll" the server just to emulate the feature of sending requests from the server to the client. Is there some other (perhaps non-socket) API that offers this?

    @sjasja: how is the socket api symmetrical?It is, trust me! Connection initiation isn't, but after that it is. (Let's assume connected TCP/IP.)
    The server does bind() and accept(), the client does connect(). After that, the connection is symmetrical: either end can issue any number of read() and write() calls in any order. You write() to a socket, it pops out from read() at the other end (though not necessarily as a single packet; TCP/IP is stream oriented, so write() "packets" can and will be glued together, or fragmented at the whimsy of network routers and friends.)
    - accept() //wait for client to send request
    - socket.getInputStream() //read request
    - socket .getOutputStream() //write responseThose don't read or write; they get streams which you can read from and write to.
    In the server, when accept() returns a new connection, you'd start a reader thread for that client. The thread would read() (or readLine() if you implement a line-oriented protocol) and handle the incoming messages. Whenever you want to write to the client, write to the stream returned by socket.getOutputStream(). You may need to synchronize writes if you have several threads that do sequences of write()s that need to arrive at the client sequentially.
    As to the difficulty of socket programming: I don't think it particularly difficult. But then I've written dozens of socket programs since my first one in '85... The Java Tutorial socket chapter shows a simple client/server pair; not terribly difficult I think. In particular, check out the KKMultiServer at the bottom of the sample server chapter.

  • Client-cert sample webapp doesn't work?

    In trying to understand how one can use client certificates with a Java webapp in the WS7, I figured I would start with the sample that comes with WS7 (in samples/java/webapps/security/client-cert). Unfortunately, the sample doesn't seem to work. I can install it just fine, and it runs, but it doesn't do what it is supposed to do. When I access the servlet from my browser, I see the message "Welcome to our Certificate secure zone." Unfortunately, it let me access this page without ever prompting me for a certificate, so it's not actually a certificate secure zone. I double-checked in the access logs to see, and sure enough index.jsp is being delivered to an unauthenticated user.
    When I examine the web.xml deployment descriptor, it's not clear to me that it should work. Here's the web.xml:
    <web-app>
      <display-name>Welcome to Certificate Security Zone</display-name>
      <servlet>
        <servlet-name>clientcert</servlet-name>
        <display-name>clientcert</display-name>
        <jsp-file>/index.jsp</jsp-file>
      </servlet>
      <session-config>
        <session-timeout>30</session-timeout>
      </session-config>
      <security-constraint>
        <web-resource-collection>
          <web-resource-name>clientcert security test</web-resource-name>
          <url-pattern>/*</url-pattern>
        </web-resource-collection>
      </security-constraint>
      <login-config>
        <auth-method>CLIENT-CERT</auth-method>
        <realm-name>certificate</realm-name>
      </login-config>
    </web-app>This web.xml seems to imply that the mere presence of a login-config will secure the entire app. The servlet specification seems a bit vague on this point, but since there isn't any auth-constraint in the security-constraint, I don't think the login-config ever applies. I think the login-config only comes into play when a security-constraint requires authentication.
    What am I missing in my understanding of the web.xml?
    What might prevent this simple sample from working properly? Could there be some other ACL or web server setting that overrides?
    Thanks,
    Tom

    If URI is not a protected resource and you want client authentication, you should use server.xml <ssl><client-auth>...</client-auth></ssl> instead of PathCheck line as I told. Value can be set to "required" or "optional".
    However, if URL is a protected resource you DO NOT HAVE to add PathCheck or client-auth element in server.xml.*
    After installing client-cert sample application using ant and ant deploy, here is what you have to do to make it work :
    1) Add in http-listener element in instance's server.xml :
       <ssl><enabled>true</enabled></ssl>2) Make sure you have a certificate named "Server-Cert" in NSS db in <ws-install-dir>/https-<instance-name>/config or change the certificate name appropriately in server.xml.
    3) To make it a protected resource, web.xml should have :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
    <web-app>
      <display-name>clientcert</display-name>
    <servlet>
        <servlet-name>clientcert</servlet-name>
        <display-name>clientcert</display-name>
        <jsp-file>/index.jsp</jsp-file>
      </servlet>
      <session-config>
        <session-timeout>30</session-timeout>
      </session-config>
      <security-constraint>
        <web-resource-collection>
          <web-resource-name>Protected Area</web-resource-name>
          <url-pattern>/*</url-pattern>
          <http-method>DELETE</http-method>
          <http-method>POST</http-method>
          <http-method>GET</http-method>
          <http-method>PUT</http-method>
        </web-resource-collection>
        <auth-constraint>
          <role-name>*</role-name>
        </auth-constraint>
      </security-constraint>
      <security-constraint>
        <web-resource-collection>
          <web-resource-name>Protected Area</web-resource-name>
          <url-pattern>/roleprotected/*</url-pattern>
          <http-method>DELETE</http-method>
          <http-method>POST</http-method>
          <http-method>GET</http-method>
          <http-method>PUT</http-method>
        </web-resource-collection>
        <auth-constraint>
          <role-name>TestRoleOne</role-name>
        </auth-constraint>
      </security-constraint>
      <login-config>
        <auth-method>CLIENT-CERT</auth-method>
      </login-config>
      <security-role>
        <role-name>TestRoleOne</role-name>
      </security-role>
    </web-app>4) And sun-web.xml should have :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Servlet 2.3//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_3-0.dtd">
    <sun-web-app>
    <security-role-mapping>
       <role-name>TestRoleOne</role-name>
       <principal-name>[email protected], CN=Franzl Alpha, UID=alpha, OU=People, O=TestCentral, C=US</principal-name>
    </security-role-mapping>
    </sun-web-app>You will be able to access http://<host-name>:<port>/ without sending client certificate from the browser.
    Now create client certificate and import this certificate in your browser.
    Access from the browser, http://<host-name>:<port>/webapps-certificatebased-security/index.jsp browser should prompt for cert selection (if so configured) and the application should get certificate.
    P/S I have tested it It works for me this way (without adding <ssl><client-auth> or PathCheck directive).

  • How do I subscribe to events as a real WLE-Server (not joint client/server)

    Hi,
    in the WLE Documentatition "Using the BEA Simple Events API" is a remarkable
    note: 'The following steps apply to a joint client/server. WebLogic
    Enterprise servers can also subscribe to events.'
    But how ??? Is there somebody with a small example ? Please help me.
    Joerg Schoppmeyer

    djak24k wrote:
    Well see, I master in edit view and I want to know how to save as 16 bit pcm <- guess i should have said that,; how do i get to select 16 bit wav in edit view?
    so how am i supposed to save it as 16 bit if its already been quantized but the File->Save as menu doesnt give me a 16 bit file structure?
    Okay - step by step instructions for two ways:
    1) Go to Edit>Convert Sample Type and select the options you want. This will convert your file to whatever format you want. When you've done this, use 'Save As' to save this conversion as a 16-bit file. Most importantly, if you just close the converted file at that point, Audition will say that it hasn't been saved (bear in mind that at this point, you've destroyed your 32-bit master) - but if you don't save it, then any changes made will be lost
    So, you have your 16-bit file preserved because you did a 'save as', and your original file is still intact, because you didn't save the conversion change.
    2) Alternatively, save a sacrificial version of the 32-bit file using 'save as' and then convert this to 16-bit and just save that as well.
    Either method works fine.

  • Siebel 8.1 mobile Client with sample db not launching IE

    I have downloaded the Siebel 8.1 Client, tools and sample db from oracle edelivery.
    I could successfully install tools and login to it.
    I installed client successfully. When logging on to the client with sample db, the uid/pwd is authenticated and the IE is launched. At this point I am getting "the page cannot be displayed" also the address is just showing "http:///"
    I have enabled IIS in my local system.
    No Siebel Servers, just client and tools with sample db.
    Please provide me a solution to this.
    Thanks,
    Koushik

    Thanks for the reply Chetan. I did a few re-installs myself to get the gateway verification working. The fact I had to do that was a real shame and reminded me of the old Siebel 98/99 days when we did re-installs "just because it worked". I thought the Siebel stack was beyond that but I digress...
    I have made it a little bit past the original issue by looking closer at the environment variables set by the siebenv.sh script. If you run this shell script in the gateway server directory you will get a bunch of bad merant ODBC libray paths set in environment variables. It appears that those paths are the cause of the "C101 Cannot start common library." I validate this by running the siebenv.sh shell script in the siebel server installation path and then overriding the ODBCINI setting to refer to the .odbc.ini file in the gateway server directory tree instead of the siebel server tree. After all, the siebel server has not been configured yet since it is a new database installation and the .odbc.ini in the directory tree is empty.
    So while I get by the original error I now get an error when the wizard attempts to run the sqlgen script as part of the overall .ucf file creation process. I have to try and work this a bit further but it appears that some of the dynamic variables are not getting populated by the wizard into the shell script. I have no idea why this is happening but will keep trying to figure it out when I have time. With any luck at all an answer will appear on this forum or metalink3.

  • Can I access the built-in queue of the client-server configuration?

    We are working on a remote lab, using LabVIEW 6i. Our solution is based on a client-server structur, where the server unit has the dual function of communicating with the client over the Internet and controlling the experimental setup. If two or more clients are using the setup at the same time, we have discovered that LabVIEW 6i is using a built-in queue system. In our work to make the client inteface userfriendly, we have the following problem. Is it possible to inform the client that he/she is in a queue, and also how many clients are in front of him/her?
    Thanks for any hints.
    Greetings, Anna Söderlund
    anna@ic
    .chalmers.se
    Solid State Electronics, Department of Microelectronics,
    Chalmers University of Technology
    Sweden

    Take a look to this sample Tcp/ip LLB.
    The server vi build-up a queue according to the number of clients connected.
    Based on this principle you can probably manage to make the server to broadcast which client it is sending data to.
    Attachments:
    tcp-ip_daq.llb ‏161 KB

Maybe you are looking for