Synchronous IO with nio

Hello,
I have been programming in Java for a while but today is my first shot at NIO.
I'm implementing a custom protocol over TCP between a java server and several Java and C clients. The classical one-thread-per-client approach works with a couple of test connections, but I'm afraid it will not scale:
- I will not have control on all clients programs
- I don't know yet the expected traffic
- I might introduce bugs as well in the sever program and leak sockets and threads
Here is the code for the classical approach:
ServerSocket server.accept()  = ...;
Socket client = server.accept();
Thread clientThread = new ClientThread(client);
clientThread.start();Where ClientThread's run method deos the following:
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
while (isConnected) {
    String pdu = reader.readLine();
    storeClientInfo(pdu);
}The key is that in order to make for a very simple protocol we designed it so that each PDU is one line of text, sent over TCP. Reading one PDU is therefiore a synchronous operation.
In order to provision scaling to many clients, we are trying to reimplement it using NIO.
We use a Selector to wait for requests, and once accepted, we register the Selector with the created SocketChannel (one per client).
One single thread dequeues reads selected by the Selector, but we are still trying to read using the synchronous BufferredReader.
When a SocketChannel has readable data, we create a Buffered reader like this:
BufferedReader reader = new BufferedReader(new InputStreamReader(socketChannel.socket().getInputStream()));
String pdu = reader.readLine(); //  throws IllegalBlockingModeException
}And as you probably expect, we get an IllegalBlockingModeException when reading the line (synchronous operation) over the (asynchronous) socket.
If my understanding is correct, the SocketChannel has to be put in non-blocking mode to be selectable by the Selector (otherwise the register(...) call throws an IllegalBlockingStateException), but it cannot be read synchronously in this non-blocking mode.
Is there any way I can connect a BufferedReader to a non-blocking SocketChannel somehow?
There would be an alternative approach, where the listeing thread reads the data from the SocketChannel into a ByteBuffer, then stuffs those bytes into a PipedOutputStream, and build a reader over a PipedInputStream.
The problem is that in this case, we need, again, one thread per client to read the data froml the reader...
There's a third approach, where we would use the "attachment" feature of SocketChannel.register() and SelectedKey; in this approach, the attachment could be a stringBuffer; each time the Selector warns us that data is readable, the data would be read from the SocketChannel into a ByteBuffer. then added to the StringBuffer. We would have to analyze the StringBuffer's content to find out whether it contains a whole line, and only then extract this line as the "PDU".
Is this a recommended approach?
Thanks in advance, and regards,
J.
Message was edited by: jduprez (some code markers had been swallowed)
Message was edited by:
jduprez

OK, thanks.
I implemented this third approach, and it works under moderate load. The difficulty though, is that what I can read from the channel is a chunk of binary data, possibly incomplete, and that possibly doesn't even translate to valid chars (for example, a 16-bits char may be cut in-between and I get only the first byte).
That orients me to a binary protocol (at least, to a protocol where I can identify "end of message " markers at the binary level).
Alternately, if I can ensure all my messages fit a UDP packet, I'd better stuff the String in a UDP packet on the client end, and decode a String from the UDP received (atomically) on the server end.
I'd lose TCP's relative reliability, but simplify the programming model for the protocol handling...
I'm still free to choose the transport at this step of the project...
Any recommendation?

Similar Messages

  • Wierdness with NIO socket on Solaris 2.10 part I

    i tried the following NioClient and MockServer, and saw some weird behavior.
    1. If i run both the client and server on the same machine on Windows, the client connects to the server, queries the instrument and gets the list of instruments back.
    2. if i run both client and server on the same Solaris 2.10 box, the NioClient doesn't get anything back from the MockServer, not even an ACCEPT
    3. if i run the client and the server on different solaris 2.10 machines, they work fine.
    have anyone seen this before? can sometone sheds some lights?
    import java.net.*;
    import java.io.*;
    public class MockServer
         public static int counter = 2;
        public static void main(String[] args) throws IOException {
             int portNumber = Integer.parseInt(args[0]);
            ServerSocket serverSocket = null;
            try {
                serverSocket = new ServerSocket(portNumber);
            } catch (IOException e) {
                System.err.println("Could not listen on port: " + portNumber);
                System.exit(1);
             System.out.println ("Listening on socket " + portNumber);
            do {             
                 Socket clientSocket = null;
                 try {
                     clientSocket = serverSocket.accept();
                     System.out.println ("starting a new client....");
                     MyThread mt = new MyThread (clientSocket);
                     mt.run ();
                 } catch (IOException e) {
                     System.err.println("Accept failed.");
                     System.exit(1);
            while (true);
    class MyThread
         private final Socket clientSocket;
         MyThread (Socket clientSocket)
              this.clientSocket = clientSocket;
         public void run ()
            new Thread (new Runnable () {
                     public void run ()
                          try
                               boolean instrumentquery = false;
                               PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
                               BufferedReader in = new BufferedReader(
                                           new InputStreamReader(
                                           clientSocket.getInputStream()));
                               String inputLine;                          
                               String successoutputLine =
                                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><return><returncode>success</returncode><detail>everything is good</detail></return>";
                               String failoutputLine =
                                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><return><returncode>failure</returncode><detail>something is not good</detail></return>";
                               String instrumentsoutput =
                                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><instruments><instrument><contract>usg-505Y</contract><cusip>12131121</cusip><deactivated>false</deactivated><halted>false</halted></instrument><instrument><contract>usg-305Y</contract><cusip>121312342</cusip><deactivated>false</deactivated><halted>false</halted></instrument></instruments>";
                               while ((inputLine = in.readLine()) != null) {
                                    System.out.println ("Receiving the following" + inputLine);
                                    if (inputLine.contains("queryInstrument")) instrumentquery = true;
                                    if (inputLine.contains("</a>"))
                                         if (instrumentquery)
                                              instrumentquery = false;
                                              System.out.println ("Sending " + instrumentsoutput);
                                              out.println (instrumentsoutput);
                                         else
                                              if ((MockServer.counter % 2) == 0)
                                                   System.out.println ("Sending " + successoutputLine);
                                                   out.println(successoutputLine);
                                              else
                                                   System.out.println ("Sending " + failoutputLine);
                                                   out.println(failoutputLine);
                                              MockServer.counter++;
                               out.close();
                               in.close();
                               clientSocket.close();}
                          catch (Exception ex)
                 }).start (); }
    }please see topic "wierdness with NIO socket on Solaris 2.10 part II" for the NioClient code as the maximum per topic is 5000.

    code for NioClient.java
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.InetSocketAddress;
    import java.net.Socket;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.nio.channels.spi.SelectorProvider;
    import java.util.*;
    public class NioClient implements Runnable {
    private InetAddress hostAddress;
    private int port;
    private Selector selector;
    private ByteBuffer readBuffer = ByteBuffer.allocate(8192);
    private List pendingChanges = new LinkedList();
    private Map pendingData = new HashMap();
    private Map rspHandlers = Collections.synchronizedMap(new HashMap());
    public NioClient(InetAddress hostAddress, int port) throws IOException {
    this.hostAddress = hostAddress;
    this.port = port;
    this.selector = this.initSelector();
    public void send(byte[] data, RspHandler handler) throws IOException {
    SocketChannel socket = this.initiateConnection();
    this.rspHandlers.put(socket, handler);
    synchronized (this.pendingData) {
    List queue = (List) this.pendingData.get(socket);
    if (queue == null) {
    queue = new ArrayList();
    this.pendingData.put(socket, queue);
    queue.add(ByteBuffer.wrap(data));
    this.selector.wakeup();
    public void run() {
    while (true) {
    try {
    synchronized (this.pendingChanges) {
    Iterator changes = this.pendingChanges.iterator();
    while (changes.hasNext()) {
    ChangeRequest change = (ChangeRequest) changes.next();
    switch (change.type) {
    case ChangeRequest.CHANGEOPS:
    SelectionKey key = change.socket
    .keyFor(this.selector);
    key.interestOps(change.ops);
    break;
    case ChangeRequest.REGISTER:
    change.socket.register(this.selector, change.ops);
    break;
    this.pendingChanges.clear();
    this.selector.select();
    Iterator selectedKeys = this.selector.selectedKeys().iterator();
    while (selectedKeys.hasNext()) {
    SelectionKey key = (SelectionKey) selectedKeys.next();
    selectedKeys.remove();
    if (!key.isValid()) {
    continue;
    if (key.isConnectable()) {
    this.finishConnection(key);
    } else if (key.isReadable()) {
    this.read(key);
    } else if (key.isWritable()) {
    this.write(key);
    } catch (Exception e) {
    e.printStackTrace();
    private void read(SelectionKey key) throws IOException {
    SocketChannel socketChannel = (SocketChannel) key.channel();
    this.readBuffer.clear();
    int numRead;
    try {
    numRead = socketChannel.read(this.readBuffer);
    } catch (IOException e) {
    key.cancel();
    socketChannel.close();
    return;
    if (numRead == -1) {
    key.channel().close();
    key.cancel();
    return;
    this.handleResponse(socketChannel, this.readBuffer.array(), numRead);
    private void handleResponse(SocketChannel socketChannel, byte[] data,
    int numRead) throws IOException {
    byte[] rspData = new byte[numRead];
    System.arraycopy(data, 0, rspData, 0, numRead);
    RspHandler handler = (RspHandler) this.rspHandlers.get(socketChannel);
    if (handler.handleResponse(rspData)) {
    socketChannel.close();
    socketChannel.keyFor(this.selector).cancel();
    private void write(SelectionKey key) throws IOException {
    SocketChannel socketChannel = (SocketChannel) key.channel();
    synchronized (this.pendingData) {
    List queue = (List) this.pendingData.get(socketChannel);
    while (!queue.isEmpty()) {
    ByteBuffer buf = (ByteBuffer) queue.get(0);
    socketChannel.write(buf);
    if (buf.remaining() > 0) {
    break;
    queue.remove(0);
    if (queue.isEmpty()) {
    key.interestOps(SelectionKey.OP_READ);
    private void finishConnection(SelectionKey key) throws IOException {
    SocketChannel socketChannel = (SocketChannel) key.channel();
    try {
    socketChannel.finishConnect();
    } catch (IOException e) {
    System.out.println(e);
    key.cancel();
    return;
    key.interestOps(SelectionKey.OP_WRITE);
    private SocketChannel initiateConnection() throws IOException {
    SocketChannel socketChannel = SocketChannel.open();
    socketChannel.configureBlocking(false);
    socketChannel
    .connect(new InetSocketAddress(this.hostAddress, this.port));
    synchronized (this.pendingChanges) {
    this.pendingChanges.add(new ChangeRequest(socketChannel,
    ChangeRequest.REGISTER, SelectionKey.OP_CONNECT));
    return socketChannel;
    private Selector initSelector() throws IOException {
    return SelectorProvider.provider().openSelector();
    public static void main(String[] args) {
    try {
    System.out.println ("the host name is " + args[0]);
    NioClient client = new NioClient(
    InetAddress.getByName(args[0]), 4444);
    Thread t = new Thread(client);
    t.setDaemon(true);
    t.start();
    RspHandler handler = new RspHandler();
    client.send(
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a><queryInstrument/></a>\n"
    .getBytes(), handler);
    handler.waitForResponse();
    } catch (Exception e) {
    e.printStackTrace();
    }

  • [svn] 1720: Bugs: LCDS-304 - Authentication not working in all cases when using security constraint with NIO endpoints .

    Revision: 1720
    Author: [email protected]
    Date: 2008-05-14 14:50:06 -0700 (Wed, 14 May 2008)
    Log Message:
    Bugs: LCDS-304 - Authentication not working in all cases when using security constraint with NIO endpoints.
    QA: Yes
    Doc: No
    Details:
    Update to the TomcatLoginCommand to work correctly with NIO endpoints.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/LCDS-304
    Modified Paths:
    blazeds/branches/3.0.x/modules/opt/src/tomcat/flex/messaging/security/TomcatLoginCommand. java

    Revision: 1720
    Author: [email protected]
    Date: 2008-05-14 14:50:06 -0700 (Wed, 14 May 2008)
    Log Message:
    Bugs: LCDS-304 - Authentication not working in all cases when using security constraint with NIO endpoints.
    QA: Yes
    Doc: No
    Details:
    Update to the TomcatLoginCommand to work correctly with NIO endpoints.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/LCDS-304
    Modified Paths:
    blazeds/branches/3.0.x/modules/opt/src/tomcat/flex/messaging/security/TomcatLoginCommand. java

  • [svn:bz-trunk] 16395: Bug: #2621264 [Regression] Small messages not working with NIO-HTTP endpoints in LCSD/trunk.

    Revision: 16395
    Revision: 16395
    Author:   [email protected]
    Date:     2010-06-02 05:00:56 -0700 (Wed, 02 Jun 2010)
    Log Message:
    Bug: #2621264 Small messages not working with NIO-HTTP endpoints in LCSD/trunk.
    QA: Yes
    Doc: No
    Checkintests: Pass
    Details: This is the BlazeDS side of the fix. This wasn't a regression, it probably never worked correctly. So, in the scenario where there's a Producer and a Consumer, and Producer sends a message for the Consumer, there are 2 messages from the server. The ACK message for Producer's send, and the actual message Consumer receives. I found that the ACK message was in small form, but the actual message was not in streaming messages. This was because we never really tried to convert streamed messages into small messages before.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoint.java
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/StreamingAMFEndpoint.java
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/StreamingHTTPEndpoint.java

  • Synchronous call with RemoteObject

    Is it possible to make a synchronous call with a
    RemoteObject? If so how?
    My application has to wait for the result. I cannot use
    result handler.
    Pls help friends.

    Not possible.
    You must use a result handler.
    Resistance is futile.
    Tracy

  • Problems with synchronizing iCal with iCloud accounts on my Mac Pro

    I have problems with synchronizing iCal with iCloud calender accounts on my Mac Pro runnning OS 10.6.8
    (error message "HTTP/1.1 403 Forbidden" på handlingen CalDAVAccountRefreshQueueableOperation.)
    It works fine on iOS devices.

    Due to lacking hardware driver compatibility i our graphic production environment we can't upgrade to Lion.
    Does that mean that it after the closing of MobileMe is impossible to synchronize calenders to Mac's running OS 10.6.8 ??

  • Help with NIO and SSL

    hi,
    anyone have code for SSL with NIO.
    Thanks

    You could start by searching this very forum for 'SSLEngine', & try Google too. Also have a look in your JDK samples.

  • How can i use GZip combined with NIO?

    Hi All,
    I have a nio client that connects a client (HTTP) and request something. I need my client to Accept-Encoding: gzip - but how will i be able to read the data into my ByteBuffer?
    I don't have a problem reading, cause it's bytes after all, but i will have a problem (i guess) determining when the reading is complete - when it finished. If i'm reading HTTP, for instance, i know i should finish reading after receiving \r\n\r\n. How should i do it for gzip info?
    Thanks,
    Snayit

    When i'm reading the HTTP i receive Content-Length X but actualy is sends the X with Y bytes (i guess it's a key, about to check in the API).
    Is there a way to combine the GZip with NIO?

  • Hello i can't open applications of my iPhone in iTunes , other ones (information, photo , books etc) open without problem. i've synchronized phone with iTunes - was no problem, quick time is works.  thank u

    hello
    i can't open applications of my iPhone in iTunes , other ones (information, photo , books etc) open without problem. i've synchronized phone with iTunes - was no problem, quick time is works.  thank u
    Tatyana

    You have Acrobat Pro on your system. It will try to open PDFs, and of course it will fail. You must uninstall it. Then, you will need a PDF reader. So install Adobe Reader. That seems quite simple, but perhaps something is wrong. If anything goes wrong with these two steps (1) uninstall Acrobat Pro (2) install Adobe Reader, then please let us know the details.

  • Selector thread in JSSE with NIO works nor parallely?

    Hi,
    I am now studying JSSE with NIO. Most of the codes are that I looked, used the Selectable Non blocking IO model. Selector thread contains many keys(keys == client sockets nearly)
    The Selector object maintains a set of selected keys and just one key is processed at a given time in a server program. So, there is no parallel work. I wonder why this keys are not processed parallely, not in batch process model in one thread?

    wow, this reply enlightens me.I have a question for you.
    here is a samle run method of runnable selector class.
    public void run() {
        while (true) {
          doPendingTasks();
          if (closeRequested) {
            return;
          int selectedKeys = 0;
          try {
            selectedKeys = selector.select();
          } catch (IOException ioe) {      
            ioe.printStackTrace();
            continue;
          if (selectedKeys == 0) {
            continue;
          Iterator it = selector.selectedKeys().iterator();
          while (it.hasNext()) {
            SelectionKey sk = (SelectionKey)it.next();
            it.remove();
            try {
              int readyOps = sk.readyOps();
              sk.interestOps(sk.interestOps() & ~readyOps);
              SelectorHandler handler =
                 (SelectorHandler) sk.attachment();         
              if (sk.isAcceptable()) {
                ((AcceptSelectorHandler)handler).handleAccept();
              } else if (sk.isConnectable()) {     
                ((ConnectorSelectorHandler)handler).handleConnect();           
              } else {
                ReadWriteSelectorHandler rwHandler =
                  (ReadWriteSelectorHandler)handler;              
                if (sk.isReadable()) {               
                  rwHandler.handleRead();             
                if (sk.isValid() && sk.isWritable()) {
                  rwHandler.handleWrite();                             
            } catch (Throwable t) {
              Shutdown();
              t.printStackTrace();
              return;
      }in this code every operation is managed by handler named "handleXXX".for example "handleRead" does reading job and also informs the side(client or server) for the data read.
    public void handleRead() {
        try {     
          int readBytes = channel.read(inBuffer);     
          if (readBytes == -1) {
            // Closing channel...
            close();
            side.socketDisconnected(this);
            return;
          inBuffer.flip();
          processInBuffer(); //if there is parts that belongs to more than one packet, seperate them and inform side(client/server)
        } catch (IOException ex) {
          side.socketException(this, ex);
          close();
      }Finally my question is if this approach is wrong.if not ,it takes more than zero time,doesn't it?
    If it is wrong , what approach do you suggest about handling operations?
    Thanks.

  • Experience with NIO client servers

    Dear Forum
    I am going to build a xml socket server and would like to use NIO rather than multi threadeding.
    What the server will do is accept client connections and run them on their own thread, these clients will then be able to send/recieve data in xml and also make simple queries to a mysql database.
    I have developed a similar system using conventional thread methods but not with NIO, the main problem that I have is i cannot see an example where a client connects a new thread is started for that client and then its reference is stored on the server allowing messages to be sent by iterating through the client vector. Is this the same for NIO?
    Any suggestions or pearls of wisdom would be great..
    Thankyou..

    If your application is basically multithreaded you are better off using the stream based sockets. If you insist on using NIO, I've posted information on multiple threads and NIO in Taming the NIO Circus. You biggest problems will come from the fact that interestOps and register block if a select is active. This forces you do do those all from the thread that does the select. You need to use a queue. Also NIO doesn't support SSL at present, maybe in 1.5.

  • I forgot my password of ipad mini and i never synchronized it with my computer

    I forgot my password of ipad mini and I never synchronized it with my computer.

    If the iPad was running iOS 7,  iCloud: Find My iPhone Activation Lock in iOS 7
    http://support.apple.com/kb/HT5818
    How can I unlock my iPad if I forgot the passcode?
    http://www.everymac.com/systems/apple/ipad/ipad-troubleshooting-repair-faq/ipad- how-to-unlock-open-forgot-code-passcode-password-login.html
    iOS: Device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    How can I unlock my iPad if I forgot the passcode?
    http://tinyurl.com/7ndy8tb
    How to Reset a Forgotten Password for an iOS Device
    http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
    Using iPhone/iPad Recovery Mode
    http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    Saw this solution on another post about an iPad in a school environment. Might work on your iPad so you won't lose everything.
    ~~~~~~~~~~~~~
    ‘iPad is disabled’ fix without resetting using iTunes
    Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
    I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
    Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
    1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
    2. Open iTunes with the iPad disconnected.
    3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
    4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
    5. Click ‘Setup as new iPad’ and then click restore.
    6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
    7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
    8. The first stage in the restore process unlocks the iPad, you are basically just cancelling out the restore process as soon as it reactivates the iPad.
    If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
    ~~~~~~~~~~~~~
    Try it and good luck. You have nothing more to lose if it doesn't work for you.
     Cheers, Tom

  • Synchronizing Calendars with iPhone/iPod Touch

    For those of us stuck in the Windows environment that do not use Outlook, there is a BIG problem synchronizing Calendars with an iPhone (or iPod Touch). It would be so helpful for Apple to open the API so programs like Sync-In-A-Blink could be written for the Calendar. I do not understand why the API is not available

    This is a user to user forum. If you may leave your feedback here:
    http://www.apple.com/feedback/iphone.html

  • Can I transfer all my apps and things wich are on my iPad 2 to a new computer by synchronizing it with iTunes?

    Hi! I have an iPad 2 since october or so, and i've been synchronizing it with my desktop computer. Now I've just bought a laptop, and i'd like to now if it is posible to synchronize it with my iPad, and transfer all my apps, photos, music, and videos wich are on my iPad.
    I already know that you can't synchronize an iPad with two computers, but  I don't know if I can transfer all my apps, music, photos, and videos to a new computer by synchronizing it with the iPad.
    Thank you

    These are two possible approaches that should work to move the existing library to the new laptop.
    Method 1
    Backup the library with this User Tip.
    Restore the backup to your new computer using the same tool used to back it up.
    Deauthorize the old computer if you no longer want to access protected content on it.
    Keep your backup up-to-date in future.
    Method 2
    Connect the two computers to the same network. Share your <User's Music> folder from the old computer and copy the entire iTunes library folder into the <User's Music> folder on the new one. Again, deauthorize the old computer if no longer required.
    Both methods should give the new computer a working clone of the library that was on the old one. As far as iTunes is concerned this is still the "home" library for your devices so you shouldn't have any issues with iTunes wanting to erase are reload.
    I'd recommend method 1 since it establishes an ongoing backup for your library.
    Should you be in the unfortunate position where your desktop has died with no backup then see Recover your iTunes library from your iPod or iOS device.
    tt2

  • Updating / Synchronizing iPhone with new computer - pruchased music lost?

    Greetings all,
    A friend of mine has an iPhone 3G which she uses happily to download music from the iTues store over Wi-Fi.
    She has never synchronized this with a computer but wants the 3.0 update.
    Do you guys know of any way that we can update without losing her purchased songs?
    In case it is relevant, I do have a MacBook that she could sync with if that turns out to be better than using iTunes on Windows.

    Purchased music can be transfered in itunes. Disable autosync, connect your phone, right click on your phone in the device list and choose transfer purchases.
    The music will show up in itunes/Store list/purchases with iphone
    Since you can only sync media content to one computer at a time, sync to the one she uses. If she syncs to your mac and changes back to her pc afterwards, all her music will be erased during the first sync.
    And convince her to backup her phone from time to time
    What's saved in a backup: http://support.apple.com/kb/HT1766
    How to: http://support.apple.com/kb/HT1414
    Message was edited by: Ingo2711

Maybe you are looking for

  • How do i update to the latest operating system on my imac

    I have been trying to install Adobe LR5 and it is telling me i dont have the necessary system req. I have checked and believe this is because i am running MAC OS X 10.6.8. I have run the software update tab and it says I'm up to date! What is the lat

  • Compile for Debug accelerator key

    Hello all, it seems it's not possible to set an accelerator key for the "Compile for debug" command, at least I cannot find how to. Any ideas? If it's not possible, I would like to suggest it for a future release. With kind regards, Ronald

  • Can any one share the Oracle Reports 6i Developer demo table scripts?

    Hi, I have to learn the Report 6i for my office project, I have installed the report 6i developer but I could not get the Demo CD, can any one share the Scripts for table (viz. Stock, stock_history , indcat ) creation and also the insert script for d

  • After 11g upgrade "REP - 501: Unable to connect...."

    Hi All, There is a problem in one of our application which is deployed on 10g AS(10.1.2.0). The database it was connecting was upgraded to 11.2.0.3 from 10gR2. A report is not getting executed from a form. But from web browser the report is working i

  • Solution: Software Update Notifications for Non-Admin-Users

    This is a follow up to [that thread|http://discussions.apple.com/thread.jspa?threadID=1642646]. Problem: Since I'm using Mac OS X the software update notification only appears if you are logged in as an user with administrative rights. In a real mult