Am I able to use Sockets in applets

I developed a server-client application in java using datagrams, and decided to try to convert the client application into an applet.
The problem was that the applet wouldn't run in a browser but it worked if I used javas appletviewer!
Tryed both JDK1.1.8 and JDK1.3.1!
Browser = IE5
Am I able to do any networking with browser at all?

My applet only connects to the server (and port) it was served from! But it still doesn't work... It works fine in an appletviewer but in a Browser I won't even get my GUI up :(
Hmmm... OK! I'll try to make a TCP connection from Applet to my server application, I've done it once before but as an application, the server then had to be multithreaded so it could work with multiple users simuntaniusly... the reason I switched over to datagram packages is that I could make the server single threaded!

Similar Messages

  • Using sockets with Applet

    Hey,
    I have a website which has an applet on one of the pages. I put in code that uses a socket to connect to MY computer. ( i want to use my computer as a server which stores data/accounts/etc) A SecurityException was thrown when I tested the applet. Is what I'm trying to do possible? or does something like this have to connect to a server which is on my website?
    Thanks

    I believe you can run something like this by signing the applet.
    And then the user has the option of allowing or disallowing a signed applet to do that kind of thing. I don't know which is the default.

  • How to use sockets in applets?

    hi,
    i wrote the following applet:
    http://spidey.bei.t-online.de/rest/java/jtv/jTV.html
    its a little applet which asks tvtoday.de for the movies which are running on the channels/time and day you specified and puts them into the table
    as a normal java application everything works fine
    but as an applet i always get an exception that im not allow to open sockets to tvtoday.de
    how comes? and is there a way to fix that?
    thx

    Applets are only allowed to create sockets back to the host that they originally came from. This is a security measure - otherwise, a trojan horse applet could be downloaded through a firewall, then open connections and do malicious things to hosts that were supposed to be protected by the firewall.
    I am not sure if there is a way the solve this. Perhaps you could sign your applet and let java pop up a "Let this applet open sockets elsewhere?" window (similar to what java web start can do), but I personally don't know of such a system.

  • Connect applet to server port using sockets? Please help!!!

    I am trying to connect a java applet to game1.pogo.com:5285 which is their gaming port. I want to make it connect from my website which is ucichess.com
    The applet can be found here: http://ucichess.com/index.html and the java console gives me a bunch of weird errors if u can take a look at it:
    network: Disconnect connection to http://ucichess.com/applet/chess2/com/pogo/util/thin/e.class
    network: Cache entry found [url: http://ucichess.com/applet/chess2/com/pogo/util/thin/m.class, version: null]
    network: Connecting http://ucichess.com/applet/chess2/com/pogo/util/thin/m.class with proxy=DIRECT
    network: ResponseCode for http://ucichess.com/applet/chess2/com/pogo/util/thin/m.class : 304
    network: Encoding for http://ucichess.com/applet/chess2/com/pogo/util/thin/m.class : null
    network: Disconnect connection to http://ucichess.com/applet/chess2/com/pogo/util/thin/m.class
    network: Connecting socket://ucichess.com:5285 with proxy=DIRECT
    Sun Jul 22 17:14:24 EDT 2007     Thread-198          ArenaServiceThin.error
    Sun Jul 22 17:14:24 EDT 2007     Thread-198          exception
    java.net.ConnectException: Connection refused: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.SocksSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at com.pogo.besl.thin.c.<init>(SourceFile)
         at com.pogo.besl.thin.a.<init>(SourceFile)
         at com.pogo.besl.arena.a.g(SourceFile)
         at com.pogo.besl.arena.a.a(SourceFile)
         at com.pogo.game.arena.chat.ChatArenaApplet.a(SourceFile)
         at com.pogo.game.arena.chat.ChatArenaApplet.b(SourceFile)
         at com.pogo.client.ping.b.run(SourceFile)
    network: Connecting http://ucichess.com/blank.html?confuser=-6956021725811422401 with proxy=DIRECT
    Applet.terminate(false, false)
    ChatArenaApplet.disposeLocals(false)
    InvalQueue thread exiting: InvalQueue-1-com.pogo.ui.a[panel8,0,0,458x403,invalid]
    ChatArenaApplet.disconnect()
    Applet.disposeLocals(false) - ChessTable
    network: Cache entry not found [url: http://ucichess.com/applet/chess2/META-INF/assets.txt, version: null]
    network: Connecting http://ucichess.com/applet/chess2/META-INF/assets.txt with proxy=DIRECT
    basic: Stopping applet ...
    basic: Removed progress listener: sun.plugin.util.GrayBoxPainter@106433d
    basic: Finding information ...
    basic: Releasing classloader: sun.plugin.ClassLoaderInfo@35dc95, refcount=0
    basic: Caching classloader: sun.plugin.ClassLoaderInfo@35dc95
    basic: Current classloader cache size: 2
    basic: Done ...
    basic: Joining applet thread ...
    basic: Destroying applet ...
    basic: Disposing applet ...
    basic: Quiting applet ...
    ChatArenaApplet.disposeGlobals()
    Timer thread exiting: ScrollbarButtonRepeater
    network: Cache entry found [url: http://ucichess.com/applet/chess2/com/pogo/ui/b.class, version: null]
    basic: Joined applet thread ...
    network: Connecting http://ucichess.com/applet/chess2/com/pogo/ui/b.class with proxy=DIRECT
    network: ResponseCode for http://ucichess.com/applet/chess2/com/pogo/ui/b.class : 304
    network: Encoding for http://ucichess.com/applet/chess2/com/pogo/ui/b.class : null
    network: Disconnect connection to http://ucichess.com/applet/chess2/com/pogo/ui/b.class
    network: Cache entry found [url: http://ucichess.com/applet/chess2/com/pogo/ui/q.class, version: null]
    network: Connecting http://ucichess.com/applet/chess2/com/pogo/ui/q.class with proxy=DIRECT
    network: ResponseCode for http://ucichess.com/applet/chess2/com/pogo/ui/q.class : 304
    network: Encoding for http://ucichess.com/applet/chess2/com/pogo/ui/q.class : null
    network: Disconnect connection to http://ucichess.com/applet/chess2/com/pogo/ui/q.class
    Applet.disposeGlobals - ChessTable
    Applet.terminate completed
    Is it possible for me to host the applet on my server and connect it to a remote server using sockets and verification or is that against java security?
    Applet.stop - ChessTable
    Applet.stop completed - ChessTable
    Applet.destroy - ChessTable
    Applet.destroy completed - ChessTable
    ChatArenaApplet.disconnect()

    Hi yoshistr, have you resolved your issue? If you have, do you mind sharing it with me?
    Thanks.

  • Communication between applets using socket

    Hi,
    we have an application in which based on certain criteria a video is bieng played in the applet on same machine.Now we have to separate the video component from the application part so that video can be played separately. they will be communicated using socket.Can any body tell me how to go about for the solution.

    To do this you must have a server application listening to a port on a server box that has a fixed IP. In your Java app, you need to create a Socket connection back to the server (may need to sign your jar - but maybe not)
    voila you're there.
    You may want to search google + these forums for my InfoFetcher class which is built to grab data from an inputstream and report updates to listeners

  • Applet using socket connection always go through proxy server

    Socket connection with socks always go through proxy server
    We have two applets in different codebases using socket to talk to each other, until now nothing new, but the problem is that we are behind a proxy server with socks and because of that, the connection always go through the proxy server even with proxy override point to the applet machine. We have tried a lof of things and until now nothing worked, it looks like the socket is ignoring proxy override configuration. We would like to know if there is a way to solve this problem making the applets comunicate to each other ignoring the proxy server. It should happen when we set the plug-in option to "no proxy host", but it doesn't. Maybe it can be a bug of JVM, I don't know, just maybe, and if it's true, any other good idea would be welcome as well.
    Thanks in advance.

    Hi,
    I am not very much sure if I can help you. In my previous experience, once you set the system property to use the proxy, then the jvm uses the proxy. If you want disable, in your code, you have to disable it.
    like System.setProperty("socksProxyHost","someHost"), Properties props = System.getProperties(); props.remove(("socksProxyHost");

  • I have the Ipod Nano. I'm traveling to Australia which has the following current: 240V AC, 50Hz. I have a travel plug adapter for the Australian electric sockets. Will I be able to use my Ipod charger with an Australian travel plug adapter or will I also

    I have the Ipod Nano. I’m traveling to Australia which has the following current:240V AC, 50Hz. I have a travel plug adapter for the Australian electricsockets. Will I be able to use my Ipod charger with an Australian travel plugadapter or will I also need a voltage converter? Australia which has thefollowing current: 240V AC, 50Hz.

    I have the Ipod Nano. I’m traveling to Australia which has the following current:240V AC, 50Hz. I have a travel plug adapter for the Australian electricsockets. Will I be able to use my Ipod charger with an Australian travel plugadapter or will I also need a voltage converter? Australia which has thefollowing current: 240V AC, 50Hz.

  • Using RMI from applets

    Hi everyone,
    I have an applet that uses RMI to communicate with an RMI registry that is on the originating server for the applet. To enable the applet to make RMI calls over port 1099 I have had to modify the policy file of my Java plug-in (to grant socket permissions to the server over port 1099).
    My understanding was that applets by default were able to communicate with their originating servers. Is this correct?
    I am asking because I want end-users to be able to use this applet in their browsers without having to perform any security configurations. At the moment, if they don't have a Java plug-in, one will be automatically downloaded and installed on their system (which is great). But, as the application currently stands, they will then have to make an additonal step to modify their policy file.
    This doesn't seem right to be. Any suggestions?
    Thanks in advance.
    Kind regards,
    Ben Deany

    I tried this a couple of years ago. In theory, it should work. If I remember correctly, I believe that the RMI API kept trying to crawl out of the sandbox by doing things that seemed to have no relation to RMI. Finally, I got a certificate and life got much simpler.

  • Downloading a binary file using sockets without length known

    Hi all,
    I'm trying to download a binary(.exe) file using socket, where the length of the file is not known. Please take a look at the code I'm using:
          var readBin = socketBin.read();
         <-- Here comes the code that checks for http Content-length header field
         ; If content-length field is available, then I'll use it to download file, else proceed with following code -->
        pBar.reset("Downloading plugin..",null);pBar.hit(readBin.length);       
                while (1)
                    binFil.write(readBin);     //'binFil' is the file, into which downloaded file is written.
                    readBin = socketBin.read();
                    pBar.hit(readBin.length);
                    if( socketBin.eof || readBin.length<=0){
                        break;}          
                binFil.write(readBin);
                binFil.close();
                socketBin.close();
    Problem is: I'm able to download file within 10 seconds when content-length is known. But when content-length is not known, its taking about 1 and half minute to download, also the progress bar gets struck for much of time.
    FYI: socket is opened in binary mode, file is getting downloaded correctly(even though it takes abt a minute). BTW Im using CS5.5 extendscript
    I'm not able to figure out where the bug is.

    Hi, Srikanth:
    Sevaral points.
    #1 When posting code, please use the web interface and the >> icon and choose Syntax Highlighting >> Java. Otherwise your code is just too hard to read and gets misformatted.
    #2 Apropos of #1, your script as written does not work, because this line:
    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$ 1/$2/$3/$4");
    has an extra space in the $1 and should be this:
    url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$1/$2/$3/$4");
    Please take an extra moment to make sure that when you asking for help, you do so in a way that makes sense. Otherwise it takes too much effort to help you, and that is frustrating.
    #3 If we instrument your script by adding a line to the while() loop:
                while (1)
                    binFil.write(readBin);
                    readBin = socketBin.read();
                    $.writeln(Date()+" Read "+readBin.length+" chars, eof is "+socketBin.eof);
                    if(  readBin.length<=0){         break;}              
    We get output like this:
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:06:56 GMT-0400 Read 631 chars, eof is false
    Mon Jul 11 2011 12:07:06 GMT-0400 Read 0 chars, eof is false
    Result: undefined
    Therefore, we can reasonably conclude that the last read at the end of the data stream returns a short read when the other side blocks.
    Unfortunately, that's clearly insufficient since you can get short reads all the time.
    I'm not sure why you say the length of the file is not known, HTTP provides it to you in the Content-Length field of the response.
    But the easy answer is to get the server to close it for you. This is easy, enough, with Connection: close. Why were you specifying
    Connection: keep-alive, anyhow?:
                var requestBin =
                "GET /" + parsedURLBin.path + " HTTP/1.1\n" +
                "Host: " + parsedURLBin.address + "\n" +
                "User-Agent: InDesign ExtendScript\n" +
                "Accept: */*\n" +
                //"Connection: keep-alive\n\n";
                "Connection: close\n"+
                "\n";
    This yields a nice tidy:
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 735 chars, eof is true
    Mon Jul 11 2011 12:26:19 GMT-0400 Read 0 chars, eof is true
    I suspect you're also better off using something like socketBin.read(64*1024) for a 64k buffer size, but it doesn't seem to effect the on-the-wire protocol, so perhaps its not so important.
    If you don't want to reply on the server

  • Networking Using Socket

    Hi,
    My team have developed a real-time remote network monitoring system. It consists of server and agent. What the agent does is send the network traffic data to server every one second by using socket. Each second we send the data to the same socket and yes we already make sure that the socket and streams used are closed after data being sent. However I still see a lot of SocketException once in a while whenever the agent tries to send the data.
    1. How can I solve this error ?
    2. Is it possible that I connect to my server just once without closing the connection and still able to send the data every second ?
    Thank you for your time.
    Regards,
    Mustafa
    Below is the code, called every one second :
          * This method sends itself into the server using compressed input/output
          * stream and then will receive back the instance of "replied" CRequest and
          * then further returns it.
          * @return CRequest
         public CRequest sendRequest() {
              SSLSocket server = null;
              GZIPOutputStream gos = null;
              ObjectOutputStream out = null;
              BufferedOutputStream bos = null;
              GZIPInputStream gis = null;
              ObjectInputStream in = null;
              try {
                   SSLSocketFactory sslFact = (SSLSocketFactory) SSLSocketFactory
                             .getDefault();
                   server = (SSLSocket) sslFact.createSocket(hostname, port);
                   String set[] = new String[] { "SSL_RSA_WITH_NULL_MD5" };
                   server.setEnabledCipherSuites(set);
                   server.setReceiveBufferSize(48000);
                   server.setSendBufferSize(48000);
                   if (milisecTimeout != 0) {
                        server.setSoTimeout(milisecTimeout);
                   gos = new GZIPOutputStream(server.getOutputStream());
                   bos = new BufferedOutputStream(gos, 48000);
                   out = new ObjectOutputStream(bos);
                   // /* Can we actually send ourselves and then receive ourselves?*/
                   out.writeObject(this);
                   out.flush();
                   bos.flush();
                   gos.finish();
                   gis = new GZIPInputStream(server.getInputStream());
                   in = new ObjectInputStream(new BufferedInputStream(gis, 48000));
                   /* Returning the newly modified request with results */
                   return (CRequest) in.readObject();
              } catch (Exception e) {
                   System.out.println("trouble sending request" + e);
              } finally {
                   if (gos != null) {
                        try {
                             gos.close();
                             // System.out.println("GOS closed..");
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                        gos = null;
                   if (out != null) {
                        try {
                             out.close();
                             // System.out.println("OUT closed..");
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                        out = null;
                   if (gis != null) {
                        try {
                             gis.close();
                             // System.out.println("GIS closed..");
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                        gis = null;
                   if (in != null) {
                        try {
                             in.close();
                             // System.out.println("IN closed..");
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                        in = null;
                   if (server != null) {
                        try {
                             server.close();
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                        server = null;
                   System.gc();
              return null;
         }

    I've been trying to modify my sendRequest function, so that It will only open and close the connection ONCE. As long as the connection is open I need to be able to send some data to the server. However I've been getting errors and stuffs like that.
    Exception:
    java.io.NotSerializableException: java.io.BufferedOutputStream
    +     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)+
    +     at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)+
    +     at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)+
    +     at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)+
    +     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)+
    +     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)+
    +     at com.inetmon.jn.commobj.CRequest.sendRealTimeRequest(CRequest.java:385)+
    +     at com.inetmon.jn.core.internal.CaptureEngine.sendDataBackToServer(CaptureEngine.java:1420)+
    +     at com.inetmon.jn.core.internal.CaptureEngine$4.actionPerformed(CaptureEngine.java:2384)+
    +     at javax.swing.Timer.fireActionPerformed(Timer.java:271)+
    +     at javax.swing.Timer$DoPostEvent.run(Timer.java:201)+
    +     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)+
    +     at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)+
    +     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)+
    +     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)+
    +     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)+
    received is null
    +     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)+
    +     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)+
    The constructor which only be called once.
    public CRequest(Cookie cookie, int id, Object information, String hostname,
                   int port) {
              this.cookie = cookie;
              this.type = RequestConstants.AGENT_SEND_REALTIME_DATA;
              this.id = id;
              this.information = information;
              this.hostname = hostname;
              this.port = port;
              try {
                   SSLSocketFactory sslFact = (SSLSocketFactory) SSLSocketFactory
                             .getDefault();
                   server = (SSLSocket) sslFact.createSocket(hostname, port);
                   String set[] = new String[] { "SSL_RSA_WITH_NULL_MD5" };
                   server.setEnabledCipherSuites(set);
                   server.setReceiveBufferSize(48000);
                   server.setSendBufferSize(48000);
                   if (milisecTimeout != 0) {
                        server.setSoTimeout(milisecTimeout);
                   gos = new GZIPOutputStream(server.getOutputStream());
                   bos = new BufferedOutputStream(gos, 48000);
                   out = new ObjectOutputStream(bos);
              } catch (Exception e) {
                   System.out.println("trouble creating socket" + e);
         }The send request, which sends data whenever I want.
         public CRequest sendRealTimeRequest() {
              try {
                   // gos = new GZIPOutputStream(server.getOutputStream());
                   // bos = new BufferedOutputStream(gos, 48000);
                   // out = new ObjectOutputStream(bos);
                   // /* Can we actually send ourselves and then receive ourselves?*/
                   out.writeObject(this);
                   // out.flush();
                   // bos.flush();
                   // gos.finish();
                   gis = new GZIPInputStream(server.getInputStream());
                   in = new ObjectInputStream(new BufferedInputStream(gis, 48000));
                   /* Returning the newly modified request with results */
                   System.out.println("managed to send once");
                   return (CRequest) in.readObject();
              } catch (Exception e) {
                   e.printStackTrace();
              return null;
         }

  • Can I Use Jce in applet

    Hi all,
    Thanks for everybody first if you look at my question and try to help me to find out the problem.
    I need to write a applet which can let people to use
    the jce's des function to encipher the user's password and
    id from the homepage.
    I write a applet already. It work fine as a application.
    But it doesn't work when I run it as a applet. Does the problem come from the security problem because I need
    to Load a sun_jce provider in a clien machine ?
    Can I use JCE in applet ?
    If it is ok to use jce in developing applet do I need to sign the applet before run it in web and which file I need to sign.
    Btw, I use the archive tag in html file to make user get the whole jce jar file. does it Ok.
    Followin is my source code
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.security.*;
    import sun.misc.*;
    import java.applet.*;
    import java.awt.*;
    public class DesApplet extends Applet{
         public static void main(String[] arg) throws Exception{
              DesApplet des = new DesApplet();
              des.CallDes();
         public void init(){
              CallDes();
         public void paint(Graphics g){
         public CallDes(){
              Cipher desCipher;
              int i;                              
              try{
                   Security.addProvider(new com.sun.crypto.provider.SunJCE());
                   KeyGenerator keygen = KeyGenerator.getInstance("DES");
                   SecretKey desKey = new SecretKeySpec("11111111".getBytes(),"DES");
                   System.out.println("Hello");
                   desCipher = Cipher.getInstance("DES/ECB/NoPadding");
                   desCipher.init(Cipher.ENCRYPT_MODE,desKey);
                   byte[] cleartext = "00000000".getBytes();
                   String value = convert_int_to_hex(cleartext,8);
                   System.out.println("cleartext is:"+value);
                   byte[] ciphertext = desCipher.doFinal(cleartext);
                   value = convert_int_to_hex(ciphertext,8);
                   System.out.println("ciphertext is:"+value);
                   desCipher.init(Cipher.DECRYPT_MODE,desKey);
                   byte[] cleartext1 = desCipher.doFinal(ciphertext);;
                   value = convert_int_to_hex(cleartext1,8);
                   System.out.println("cleartext1 is:"+value);
              }catch(Exception e){System.err.println(e);}
         public String convert_int_to_hex(byte[] value, int len) {
         int i;
         int j;
         byte tmp;
         byte[] temp = new byte[len*2];
         char[] chars = new char[len*2];
         String result = new String();
         for (i=0; i<len; i++)
         if (value[i] < 0)
         temp[i*2] = (byte)((value[i] & 0xF0) >>> 4);
         temp[i*2+1] = (byte)(value[i] & 0x0F);
         else
         temp[i*2] = (byte)(value[i] / 16);
         temp[i*2+1] = (byte)(value[i] % 16);
         for (i=0; i<len*2; i++)
         if (temp[i] > 9)
         chars[i] = (char)(temp[i] - 10 + 65);
         else
         chars[i] = (char)(temp[i] + 48);
         result = result.concat(result.valueOf(chars));
         return result;

    I have a server and a client.
    Server has jdk1.4. client is an applet. I need to encrypt the username and password that are sent from client to the server.
    I am able to encrypt and decrypt using JCE's DES on server side, since jdk1.4 has JCE provider installed by default. Since the applet may be running on any browser which may not have JCE supported. Is it possible for me to send the JCE jar file along with the applet and somehow enable the client applet to encrypt the user name and password and send to server.
    Thanks a lot,
    Gagan.

  • File transfering using Sockets

    can anybody help me to find the simple sample code for file transfering. i m new to java and having problem in client server assignment. sending message (chatting) is done, but i still need file transfering part. only one file at one time is good enough.
    thanks.
    moe

    Since you're asking for help with your homework, I won't give you any code but I will point you in the right direction. Sockets can be used to stream data and files also use sockets. If you put the two together, you'll be able to stream your files between JREs.
    Shaun

  • Send a picture file using sockets

    Hi,
    Could someone please tell me how I can send a picture file using sockets across a TCP/IP network? I have managed to do it by converting the file into a byte array and then sending it but I dont see the data back at the client when I recieve the file. I just see the byte array as having size 0 at client.
    Byte array size is correct at client side.
    //client code
    System.out.println("Authenticating client");
              localServer = InetAddress.getLocalHost();
              AuthConnection = new Socket(localServer,8189);
              out = new PrintWriter(AuthConnection.getOutputStream());
              InputStream is = AuthConnection.getInputStream();
              System.out.println(is.available());
              byte[] store = new byte[is.available()];
              is.read(store);
         ImageIcon image = new ImageIcon(store);
              JLabel background = new JLabel(image);
              background.setBounds(0, 0, image.getIconWidth(), image.getIconHeight());
              getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
    //extra code here
              catch (UnknownHostException e) {
    System.err.println("Don't know about host: LocalHost");
    System.exit(1);
              catch (IOException e) {
    System.err.println("Couldn't get I/O for "
    + "the connection to: LocalHost");
    System.exit(1);
    //server code
                   DataOutputStream out = new DataOutputStream(incoming.getOutputStream());
                   FileInputStream fin = new FileInputStream("3trees.gif");
                   byte[] b = new byte[fin.available()];
                   int ret = fin.read(b);
                   out.write(b);

    i used OutputStream as
    OutputStream out = incoming.getOutputStream(); and flushed the stream too.
    But I still get the same output on the client side. I tried sending a string and it works , but I cant seem to be able to populate the byte array on the client side. It keeps showing zero. Please advise.
    Thank you.

  • Will I be able to use my existing display?

    When I get a Mac Pro, I want to get an ATI Radeon X1900XT graphics card. I notice that it has two dual-link DVI ports. Does that mean I have to use a 30" display?
    I need to keep using my existing Apple Studio Display which has these characteristics (from system profiler):
    Display Type: CRT
    Resolution: 1024 x 768 @ 99 Hz
    Depth: 16-bit Color
    Core Image: Not Supported
    Main Display: Yes
    Mirror: Off
    Online: Yes
    Quartz Extreme: Not Supported
    Does anyone know if I will I be able to use that card and that type of display?

    Yes, you will be able to use the ATI graphics card to drive just about any monitor on the planet, including the giant 30" display. Your existing display will work just fine. In fact if you have another spare monitor around you can hang that one on the second output socket and have two with no problems at all.
    If you have an older Apple Desktop Connector on your monitor you may need a cable adapter. Other than that it should be blindingly fast at that resolution.
    [localhost] SIGALARM

  • Problem if mail sent using sockets using j2me devices

    Hi,
    I have a strange problem. I am sending a mail using j2me ( using sockets ). The mail will be sent successfully. But when tried to access using pop service, that mail is never seen in the server.
    I sent a mail from j2me device to gmail account - I can see that mail using the gmail login, but using pop service i am not able to see that mail.
    If I send a mail from browser - I can see the mail in both, the browser and also the pop service.
    Can anyone explain what is the problem ?
    Thanks in advance

    Would you be so kind as to edit your original post and add [SOLVED] to the subject?
    Thanks,
    Craig...

Maybe you are looking for

  • Iomega eGo 2TB USB/Firewire 800 drive not working with Time Machine.

    The drive I had for Time Machine died and I replaced it with an iomega eGo 2 TB USB/Firewire 800 drive. Time Machine finds it and backs up the disk when I first boot up but then it seems like the drive goes off line. At that point, when Time Machine

  • Factory method

    Hey all, I am tying to learn factory method and working on an example from the Oreilly AS3 Design patterns book. I am attempting figure out how all the classes work together in this design pattern and I have a question I am hoping someone might be ab

  • Parse a WebPage and Extract Data

    Hi, i've figured out how to get an html source using a java class posted earlier on this forum. I wanted to find out what is the best and easiest way to extract information from it. I have been searching the web and read a lot about using XML. Is tha

  • Sculpture benchmark with Macbook? (NOT Pro)

    Just curious if anyone has had the opportunity to do the sculpture benchmark test with a new MacBook? I've got one on order and am curious to see what kind of performance we're talking. Of course I could always wait until mine arrives....

  • Burning dual layer discs

    Hi all, so i finally decided to bite the bullet and divorce my PC, Windows and almost everything microsoft, my new life with Mac is fantastic!!! so, a little advice is what i need with me being still new to the world of mac. last night i tried to bur