Problem with receiving message over socket

class TCPClient5 {
public static void main(String argv[]) throws Exception
java.io.InputStream s = null;
java.io.InputStreamReader r = null;
try {
URLConnection uc = new URL("http://www.countryflower.com/Country_Flower_Home_Pic.jpg").openConnection();
s = uc.getInputStream();
     System.out.println(uc.getContentLength());
int x = uc.getContentLength();
BufferedInputStream buffer = new BufferedInputStream(s);
File f = new File("c:\\Users\\dell\\Desktop\\image\\image.jpg");
DataOutputStream outdata = new DataOutputStream(new FileOutputStream(f));
int n = 0;
while(true) {
n = s.read(byte[x] buffer,0,buffer.length); ----- here I am getting error
if (n == -1) break;
if (n == 0) {Thread.sleep(50); continue;}
outdata.write( buffer,0,buffer.length);
outdata.close();
finally {
//if (b != null) b.close();
if (r != null) r.close();
if (s != null) s.close();
In above code I am getting error .................
I am unable to receive message from server..........Please help me with code

n = s.read(byte[x] buffer,0,buffer.length); ----- here I am getting errorHere we are unable to read your mind. What error? The syntax you've typed isn't correct, is that really what you have?
if (n == -1) break;
if (n == 0) {Thread.sleep(50); continue;}'n' can never be zero. Omit this line.
outdata.write( buffer,0,buffer.length); That should be outdata.write(buffer, 0, n);

Similar Messages

  • I keep having the same problem with my messages over and over again. My number is not checked in my message settings it just unchecks itself

    I keep having the same problem with my messages over and over again. My number is not checked in my message settings it just unchecks itself

    Dear Tomarshe
    I had the same problem a couple of weeks back.
    What I did was that I restarted that Ipad of mine and voila!
    Problem solved!
    hope this helped!
    - DASHdotDASHdot

  • Problem with Sending files over Sockets

    Hi. I have a problem when I try to send files over sockets. When I send text files it works well but when I try to send .jpg or other kind of files it doesn't work well because some characters are wrong, I hope you can help me.
    Here is my code:
    //Sender code
    import java.io.*;
    import java.net.*;
    class Servidor{
         Servidor(){
              try{
                   String arch="art.jpg";
                   ServerSocket serv=new ServerSocket(125);
                   Socket socket=serv.accept();
                   System.out.println("Conectado");
                   int c;
                   BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                   FileInputStream fis=new FileInputStream(arch);
                   File f=new File(arch);
                   bw.write(""+f.length());
                   bw.newLine();
                   bw.flush();
                   System.out.println("Escribiendo");
                   while((c=fis.read())!=-1){
                        bw.write(c);
                   bw.flush();
                   fis.close();
                   System.out.println("Terminado");
                   while(true){
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Servidor();
    //Client code
    import java.io.*;
    import java.net.*;
    class Cliente{
         Cliente(){
              try{
                   Socket socket=new Socket("localhost",125);
                   System.out.println("Conectado");
                   BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
                   long tam=Long.parseLong(br.readLine());
                   long act=0;
                   FileOutputStream fos=new FileOutputStream("resp.jpg");
                   System.out.println("Recibiendo: "+tam);
                   while(act<tam){
                        fos.write(br.read());
                        act++;
                   System.out.println("Terminado: "+act+" / "+tam);
                   fos.close();
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Cliente();
    }

    I don't think you want BufferedReader and OutputStreamWriter, you want ByteArrayOutputStream and ByteArrayInputStream . The problem is that you are sending jpegs (binary data) as text.

  • Problem with sending message over network

    ssc = (ServerSocketConnection) Connector.open("socket://:5000");
    sc = (SocketConnection) Connector.open("socket://localhost:5000");my app works over the network in the emulator, but wont work on real devices, or do i just need to pair somehow with the device before i start.
    are the above lines okay is it meant to be localhost that's what they use in the socket part of the network demo that comes with the wireless toolkit, anyone have any ideas why that app doesnt seem to work for me on the real devices.
    i know for bluetooth you have to pair with the device before running the application do you have to do something like this

    Vishal,
    Couple of questions. 
    How are you sending this message.  Is it a message that you create and send Internally with an attachment.
    As you reply me, please also check if the <b>Attachments folder</b> has been set under <b>Administration > System Initialization > General Settings.....Path Tab</b>
    SBO tries to copy the attachment from the location you select to the Path defined for Attachments.
    Let me know
    Suda

  • Problems with receiving signed message in outlook

    Hello
    I have a problem with signing message using Javamail. I use a sample program code that I got from some tutorial - it seems to work fine but when I receive the message using outlook express there are fallowing warnings:
    - the message has been changed by untrusted people
    - the e-mail address from the certificete:... (here ma address) doesn't match the address of the sender:... (here no adress)
    I set all the varables: 'sender', 'replyTo', 'return-path' and 'from' with my address used in the certificate. I don't know why there is no address after the word: sender. Maybe some of you had such a problem, solved it and could share with me what is wrong with my message?
    ania

    Hi
    It's me again. I solved the problem.
    The first warning was because I changed the message after signing it, before sending :), and the second (that was worse) was because I was setting up all possible fields: sender, from, reply to and return-path - only sender should be set - now everything works great :)
    ania

  • Problem in receiving messages via RFC Sender Adapter

    Hi,
    I have problems in receiving messages from SAP backens systems. Sometimes we are getting all messages sometimes not. Strange.
    We are transfering report-results via asynchronous RFC calls. To avoid big message sizes we split them up in max. 1000 rows blocks.
    Each RFC call on backend side is completed with COMMIT WORK!
    We increased the number of connections in the RFC sender adapter. Then it was better, but the problem still exists! Not so often, but sometimes !?!?!
    I hope everybody can help me. Thanks a lot!
    best regards,
    Hannes

    hi,
    when you don't receive messages what do you see in SM58
    on the r3?
    any errors over there?
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Error while posting GR from EWM in ECC. "Problem with receiver finding"

    Hi
    I have completed putaway of inbound delivery in EWM. This has triggered PPF to ECC for GR posting. This is stuck in ECC SMQ2 with error "Problem with receiver finding".
    I have checked ECC>EWM interface configuration. Handling unit management setup in ECC and EWM. Do not see any issues there. Also tested GR account postings with IM storage location for Po in ECC. This is also working fine...so no issue with account determination.
    Unable to figure out what is causing issue. Please help. Thank you.
    Best Regards
    phani sai MN

    Hi All
    Thanks for your responses. Issue was with distrubution model fiter parameters. for message type InboundDelivery.Deliverychange there was additional filter parameter for logical system. Removed values for logical system and only retained warehouse number.
    With this issue is resolved. GR is posted succesfully in ECC.
    Best Regards
    Phani sai MN

  • Problem with Nokia Messaging on my N97 (V22)

    Since afew weeks I have a strange problem with Nokia Messaging on my N97.
    I receive emails using Nokia Messaging (V10.2.26) with a date shown incorrect as 01.01.0000 and the email then can’t be opened/read.
    This happens either on 3G connection as well as WLAN and it seems to be by random, not only HTML-emails or emails with text only.
    I have uninstalled Nokia messaging already and reinstalled V10.1.24 but the problem still remains.
    Is there any idea how to fix this issue because it is quite annoying and I can’t use the full functionality of my cell phone?

    millic wrote:
    ceroberts75,  I remember from your other posts somehow server thinks you already have an account with the email you are trying to configure and you/nokia support is not able to get access to it. Different people have resolved this issue in different ways. For me it was just another way. Thought it might help someone.
    absolutely m8.  thats why i gave you a kudos.
    the challenge is that NM has been unruly as of late...and believe when i say that i have literally been on the phone teching nokias support up to tier 2 and creating, canceling, trying new acounts with different email, different ways of creating them, with wifi, gprs...and praying for hours accross mutliple phone calls
    but to no avail, are the devices we are using connecting and syncing...even with thier n900 specialist which i had to help him!   lmao. 
    another option for a solution is alwayhs welcome as there are more then one way to skin a cat.
    i hope it works for him and others as i kno9w thesome that are just giving up on it.

  • Problem with Receiver File adapter

    Hi
    I have a problem with receiver file FTP adapter, while writting file in target folder, connection is failing, after retries, it writting file again. How to avoid this situation, is there any way to write the leftout part in the file.
    VS

    Hi
    Thank u all,  Problem is solved, i changed write mode to Over write existing file. It is working fine.
    VS

  • Problems with receiving

    hello again! : ( I have problems with receiving mails, my
    installation is local, therefore I am using telnet but it marks errors
    to me you have some idea?
    bash-2.03# telnet pegaso.qoslabs.com 25
    Trying 192.168.20.20...
    Connected to hostname.com.
    Escape character is '^]'.
    220 pegaso.qoslabs.com -- Server ESMTP (Sun ONE Messaging Server 6.0 Patch 1 (built Jan 28 2004))
    MAIL FROM: [email protected]
    250-2.5.0 No HELO/EHLO seen; continuing anyway, [192.168.20.20].
    250 2.5.0 Address Ok.
    RCPT TO: [email protected]
    550 5.1.1 unknown or illegal alias: [email protected]
    RCPT TO: katiuskac
    550 5.1.1 unknown or illegal alias: user
    DATA
    554 5.5.0 No recipients have been specified.
    QUIT
    221 2.3.0 Bye received. Goodbye.
    Connection closed by foreign host.
    what is the solution?
    do you have any idea?

    If the MTA believes that you have an error, it will give you the 5.5.1 error.
    The error may be any of several provisioning problems. Since you haven't sent me the ldap entry for the user, I really can't tell which error you may have made.
    A common error is the value you placed in "mailhost".
    This needs to be the Fully qualified name of your mail server, not an alias. If you desire to use an alias for the system, you need to make additional configurations.
    Please believe me, I'm trying to help you, but when there are dozens of possible errors, and I have no data to examine, I can't tell which error you may have made.
    I do know that if you correctly provision a user, that user will work.

  • Safari have problems with streaming radio over flash

    Hello,
    since my update on MAC OS LION have my safari problem with radio streaming over flash.
    For testing: http://shoutcast.flashradio.info/#/House/814384/
    In all browsers on all platforms will this work. Just on the combination from MAC OS LION and Safari 5.1 we get the io error #2032.

     Try changing some Advanced wireless settings on the router. Open the setup page of the router and go to Wireless tab. Click on Advanced wireless settings. Change beacon Interval to 75, RTS threshold to 2304. Save the settings.
    Change the wireless channel to 11.
    An 802.11n router can also work with 802.11g and even 11b devices. But these much slower devices force the router to slow down to talk to them, which means a big throughput hit. Fortunately, the "legacy" mechanisms are pretty efficient and reduce throughput only when the slower devices are actively transmitting or receiving. Either upgrade to all 11n clients, or use a separate 802.11g router to handle your "legacy" stuff.

  • See Below. I have a problem with receiving email. Sending is ok. This is for my Thunderbird email account.

    "An error occurred while sending mail. The mail server responded: 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table. Please check the message recipient [email protected] and try again."

    ''I have a problem with receiving email.''
    ''An error occurred while sending mail.''
    Who is right here?
    ''This is for my Thunderbird email account.''
    There is no such thing as a 'Thunderbird email account'. Thunderbird is an email client, and you use it to retrieve mail from an account you created with your email provider.

  • Problems with File Transfers Over Firewire 800

    Problems with File Transfers Over Firewire 800.
    Over the past month, I have had problems when transfering files from my harddrive, over Firewire 800 to a portable drive. I usually transfer very large files (20gb or more) to the portable drives for moving files around. When I drag a file over to copy onto a drive, the transfer starts normally. If I drag more files to copy over, the computer screen goes darker and a large icon comes up that looks like a power button icon. It tells me to restart, so I have to do a hard shut down on my G5. Weird. I also get the dark screen of death sometimes when I am transfering those large files and open another application to do some work while it's copying. It's killing me. I am having to sit here and wait for the transfer to finish before I can do anything.
    Any thoughts...
    Dual 2.7 GHz PowerPC G5
    Mac OSX 10.4.3
    Dual 2.7 GHz PowerPC G5   Mac OS X (10.4.3)  

    Have you run the Apple Hardware Test? Sounds like it could be a RAM problem.

  • I have two Iphones with different email addresses sharing one Apple ID. Will that cause problems with using messaging and FaceTime?

    I have two Iphones 5 with different email addresses sharing one Apple ID account.Both are using IOS 8.
    I would like to set up a new Apple Id for one of the phones and remove it from the old account.
    If I do that, can I move all of the purchased apps and songs to the new Apple account?
    Also, will sharing one Apple ID account with two devices cause problems with using messaging and FaceTime?

    Sharing an iCloud account between two devices can be done without causing issues with iMessage and FaceTime, just go into Settings for each of these functions and designate separate points of contact (i.e. phone number only, or phone number and unique email address).  While that works, you'll then face the problem where a phone call to one iPhone will ring both if on the same Wi-Fi network -- but again, that can be avoided by changing each phone's settings.
    Rather than do all that, don't fight it -- use separate IDs for iCloud.  You can still use a common ID for iTunes purchases (the ID for purchases and iCloud do not have to be the same) or you can use Family Sharing to share purchases from a primary Apple account.

  • Problem with instant message in clustered environment

    Hello, I have some problem with Instant Message service.
    We need to use it in our Production Environment (a clustered emvironment with a central instance, two dialog instances and two web dispatchers), some months ago we tested it in Development Environment (not clustered emvironment, just a single system) and it worked fine.
    So I did the same configurations on Production Environment but it did not work.
    But if I access on my portal (Production Env.) by the central instance (avoiding the dispatchers) the instant message service works.
    I think it can be a web dispatcher's configuration problem, in its logs I found the message :
    "<i>[Thr 3700] *** ERROR => htmlEncode: called with empty string [icpif.cpp 847]</i>"
    I' ve repeated the same configuration done in Dev.Env. (no dispatcher) on the Prod.Env. (with 2 dispatcher), is possible that I'm missing some configurations??
    Could someone helps me?
    Best Regard
    null

    Hi Alessandro,
    unfortunately I got the same problem but I haven't found the solution yet.
    Hoping someone will help us.
    Regards  Nicola

Maybe you are looking for

  • Setting up a USB external Drive with USB Hub on Airport Extreme

    I have successfully hooked up the Airport Extreme Base Station (n) with two printers using a USB Hub. I am now trying to hook up an external hard drive(acomdata 250 gb). When I plug the hard drive into the Hub and turn the drive on the Airport Extrem

  • XPath expressions in XmlCursor / XmlObjects

    Hi all, I tried to get a portion of an XML by using XPath Expressions as follows: String xPathExpression = "declare namespace xq='http://inti.notariado.org/indices' " + "$this/xq:RULES/xq:RULE[@disabled]"; A simple example of an xml <rules> <rule dis

  • Does performance point support effective username on https in sharepoint 2013

    I see that analysis services effective username is supported from Sharepoint 2013. In Central admin==> manage services==>Performance point service app there is a note saying effective user name is not supported in https or powerpivot.  But in the tec

  • Bug in Notes app?

    Does anybody know if there is a bug in the Notes app that comes on the iPhone? I opened a new note and typed "Shopping", hit return and typed "Hy". The little helper box shows "By", but I want "Hy-vee", so I hit the numbers keypad and type the "-". I

  • Search contacts by Alzheimer

    I forget names. But, I can often think of something about that person that helps me categorize them. It could be city, spouse name, hobby, occupation.  I want to search my contacts by using that association to get to the name. The Palm OS does it nic