Why write(13), write(10)?

I have a book that contains a sample program that illustrates the use of Sockets, and there is some code in that program that I do not understand. It says:
String host = new String("somehost.com");
int port = 4444;
Socket sock = new Socket(host, port);
DataOutputStream out = new DataOutputStream(sock.getOutputStream());
out.writeBytes("Some Text");
out.write(13);     //this is the part
out.write(10);    //I was wondering about
out.flush();
...Why does this say write(13) and write(10)? I would really appreciate some help. Thank you.

so that the other side would know that end of line has been reached.
on unix the EOL char is \n tahts 10, but on Windows you find it to be \n\r tahts 10 and 13, and the same EOL sequence is used in networking as well (if i'm not mistaking)
i hope it's more clearer for you now.

Similar Messages

  • Good morning! i'd like to know why when I write an email in Mail, it creates numerous copies each second which fill the trash box. My email is set up with IMAP and is a gmail account. Thanks

    good morning! i'd like to know why when I write an email in Mail, it creates numerous copies each second which fill the trash box. My email is set up with IMAP and is a gmail account. Thanks

    Open Mail preferences and select Accounts then MailBox Behavior. You probably need to unclick the safe draft to server.

  • Why is the write speed so slow to my NAS

    Hi, I am trying to improve the write speed from my MBP to the NAS.  I am using the Thunderbolt ethernet adapter connected to an Airport Extreme 7.6.1 using a wired connection. I have a Synology DS213 with a wired connection to the Airport Extreme as well. I am using CAT6 cables.
    In testing my performance, I noticed writing files from my MBP to the NAS was very slow; whereas my read performance was much better.  Please see the tests below to explain this further.
    Using the Blackmagicdesign Disk Speed Test Utility using a 5Gb test file written to the NAS, I see the following:
    Write speed is 7 to 8MB/s  This write speed is what concerns me.
    Read speed is between 60 MB/s and 75 MB/s
    Using 2 finder windows (drag a file from one window(MBP) to the other(NAS)) and watch the disk activity on the Activity Monitor with a 1Gb file
    When writing a file to the NAS from the MBP:
    Write speed will burst to 19 to 23 MB/s but it will drop to below 10 MB/s at times.
    When writing a file to the MBP from the NAS
    Write speed is: 46 to 60 MB/s
    Why would the write speed from my MBP to the NAS be so slow ; whereas, the write speed from the NAS to the MBP is very fast.
    Synology has 2 WB 'green' disks configured as raid 1.   I understand that part of the influence of writing from the NAS to the MBP is utilzing the advantage of writing to a SSD ; whereas, writing to the NAS it is writing to a slower drive.  
    Is 19 to 23 MB/s burst with dips below 10 MB/s during a copy typical?   The other thing is I dont understand why the Disk Speed Utility never records write speeds to the NAS over 10 MB/s whereas the Activity Monitor will show the bursts at times of 19 to 23 MB/s
    If 7 to 8 MB/s write speeds is too slow, what can I look at to improve this?  Since writing the file in the other direction is pretty fast considering, how could the issue be a network one?

    I was transferring my iPhoto library from an older MBP to a new retina and having the same issue - transfers almost immediately slowing to less than 100k/sec over my beautiful Time Warner-provided WiFi router using regular OSX folder sharing.  I couldn't find any software updates as some other similar threads suggested.
    I put my iPhoto library in a .tar.gz archive and that immediately transfered at about 7mb/sec, much much faster!  So, without having diagnosed the issue, perhaps I've uncovered evidence that one or both of my machines doesn't like transferring big file trees.  I bet a zip or any other archive would do the trick.

  • Why non-blocking write would block usually?

    I want to know that why my non-blocking socket's write will consume such a long time. sometimes 400ms worst.
    and this is my strace result:
    19:17:48.886276 write(1306, "\n\365\31:h#\t\7\237\20\3\21\337\36\276\317\6\3023\6\204\223,-\306\30\322\"\f\1\30\0\n"..., 121) = 121 <0.403088>
    It use 0.403088 seconds to finish the write, And I am sure of that the fd 1306 is a non-blocking socket.
    Another records shows:
    19:15:27.949736 write(995, "\n\365'\236UN\24\10\26Y\16\30\373\26\306\240\36\267z\10\20\342\f\17\301&\253\240\2\325\\\314\354"..., 160) = 160 <0.368412>
    19:15:28.410003 write(1466, "\n\365't\360`\20\10\20\342&\253\240\36\267z\10\26Y\26\306\240\16\30\373\2\325\\\f\17\301\314\354"..., 194) = 194 <0.199244>
    19:15:28.627854 write(1821, "\n\365'\260*s*\f\17\301\16\30\373\10\26Y\10\20\342\26\306\240\2\325\\&\253\240\36\267z\314\354"..., 160) = 160 <0.397758>
    19:15:29.029411 write(755, "\n\365'f\356\1\1&\253\240\36\267z\10\26Y\26\306\240\16\30\373\f\17\301\2\325\\\10\20\342\314\354"..., 160) = 160 <0.399817>
    19:15:29.440261 write(614, "\n\365'b\345H\6\36\267z&\253\240\10\26Y\2\325\\\26\306\240\10\20\342\f\17\301\16\30\373\314\354"..., 305) = 305 <0.396985>
    19:15:29.846446 write(892, "\n\365'\354\2256t\16\30\373\f\17\301\2\325\\\10\20\342\10\26Y&\253\240\26\306\240\36\267z\314\354"..., 160) = 160 <0.399170>
    19:15:30.250257 write(515, "\n\365'\376\343\214i\10\20\342\26\306\240\f\17\301&\253\240\10\26Y\2\325\\\36\267z\16\30\373\314\354"..., 231) = 231 <0.398990>
    19:15:30.652666 write(262, "\n\365'\274so\6&\253\240\10\26Y\2\325\\\26\306\240\36\267z\16\30\373\f\17\301\10\20\342\314\354"..., 168) = 168 <0.396569>
    19:17:46.885289 write(908, "t\213\16\222\0\0\0\0\240@\33L\0\0\3219\0\0\333J\0\0\2218\0\0\2\0|\203\16\222\0"..., 189) = 189 <0.396330>
    19:17:47.351419 write(1529, "\n\365\31\352\2\10\252\36\276\317\30\322\"\6\204\223\6\3023\f\1\30\7\237\20\3\21\337,-\306\0\n"..., 128) = 128 <0.293829>
    19:17:47.651080 write(683, "\n\365\31~ZG=\30\322\"\6\204\223\7\237\20\36\276\317\6\3023\3\21\337,-\306\f\1\30\0\n"..., 121) = 121 <0.398178>
    19:17:48.062419 write(175, "\n\365\31\224H\260\313\f\1\30\6\3023\3\21\337\36\276\317\6\204\223\7\237\20,-\306\30\322\"\0\n"..., 121) = 121 <0.398811>
    19:17:48.467481 write(569, "\n\365\31v5]H\3\21\337\30\322\"\f\1\30\6\3023\6\204\223\7\237\20,-\306\36\276\317\0\n"..., 121) = 121 <0.192335>
    19:17:48.663023 write(173, "\n\365\31\376\nJ\0\36\276\317,-\306\7\237\20\30\322\"\3\21\337\6\204\223\6\3023\f\1\30\0\n"..., 121) = 121 <0.206703>
    19:17:48.886276 write(1306, "\n\365\31:h#\t\7\237\20\3\21\337\36\276\317\6\3023\6\204\223,-\306\30\322\"\f\1\30\0\n"..., 121) = 121 <0.403088>
    BTW, This application is for the service of 3-4K client.
    And I do want to ask that:
    1.Why non-blocking write will make our process lose the CPU ( I think it is blocked ).
    2.What our process waiting for? Why not just return EAGAIN?
    3.Can we avoid this problem?
    Our server's info:
    Linux hz172-96 2.6.32-bpo.5-amd64 #1 SMP Mon May 2 11:40:03 UTC 2011 x86_64 GNU/Linux
    Looking forward to your answer, Thank you!

    thank you for your answer.
    and i have resolve this ploblem in using the linux kernel 2.6.30, using  kernel  2.6.32 before.
    but, i don't kown Is there some bug in linux kernel 2.6.32 or for other reason.

  • Why does DataOutputStream write Boolean as 1 Byte?

    Im trying to conserve space in a file storing booleans.
    why does dataoutputstream write booleans as a byte?
    is there a way to write a bit only?
    thanks!

    Hi,
    A boolean does even allocate at least 8 bits when it is declared in the code.
    From the VM spec:
    "3.2.4 There Is No boolean Type
    Although Java defines a boolean type, the Java Virtual Machine does not
    have instructions dedicated to operations on boolean values. Instead, a
    Java expression that operates on boolean values is compiled to use the int
    data type to represent boolean variables.
    Although the Java Virtual Machine has support for the creation of arrays of
    type boolean (see the description of the newarray instruction), it does not
    have dedicated support for accessing and modifying elements of boolean
    arrays. Arrays of type boolean are accessed and modified using the byte
    array instructions.1
    For more information on the treatment of boolean values in the Java Virtual
    Machine, see Chapter 7, "Compiling for the Java Virtual Machine.""http://java.sun.com/docs/books/vmspec/html/Overview.doc.html#22909
    /Kaj

  • Why my apple write the item is over 20mb when i want to buy item? What shall i do to download?

    Why my apple write the item is over 20mb when i want to buy item? What shall i do to download item over 20 mb its a new problem

    It usually means you're connected to a 3G network and the cell provider won't allow a download that big over the network. Try to download it when you are connected to a WiFi network.

  • Need to an OutputStream or Writer to write in a file

    Hello,
    I my java class, I need to an OutputStream or a Writer to write in a file. The problem is that I am in a webapp.
    To get an inputStream, I use this :
    InputStream is = this.getClass().getResourceAsStream("RELATIVE_PATH_IN_WEBAPP");
    But it doesn't exist a correspondance for the outputstream.
    With this code :
    Writer writer = new FileWriter("RELATIVE�_PATH_IN_WEBAPP");
    I cannot find the file because it looks for my application server relative path.

    Ok but I think it doesn't help me.
    To explain : I have a servlet that calls a service in a Java class :
    public class MyServlet extends HttpServlet{
    public void init(){
    MyService service = new MyService();
    String file = "RELATIVE_PATH_IN_WEBAPP//myfile.xml";
    service.createFile(file);
    In MyService class :
    public void createFile(String file){
    XMLWriter writer = new XMLWriter( //dom4j API
    new FileWriter(file) );
    writer.write( document );
    But this doesn't looks for my file in the relative path of the webapp.

  • What triggers a write-through/write-behind of entry processor changes?

    What triggers a write-through/write-behind when a cache entry is modified by a custom entry processor (subclass of AbstractProcessor)? Is it simply the call to Entry.setValue() that triggers this or are entry modifications detected in some other way?
    The reason I am asking is that in our Coherence cluster it looks like some entry modifications through entry processors have not triggered a write-behind, and I see no logical pattern as to which ones have and which ones haven't except that some specific entries are just never written to our database. We see from our logs that our implementation of the CacheStore.store() method is not called in these cases, and we also see that the cache entry has been modified successfully.
    We are using Coherence 3.3 on a three machine cluster with 8 nodes on each machine, accessed from clients through a TCP extend proxy.
    Regards,
    Mikael Carlstedt
    mBlox Inc
    Edited by: user3849225 on 16-Sep-2010 04:57

    Hi Mikael
    Calling setEntry() will result in a call to the CacheStore.store() method unless the value you are setting is the same as the existing entry value. If you are using writebehind then storeAll() will be called instead of store() if there are multiple entries waiting to be stored. Writebehind will also coelesce entries so that only the last entry for a given key will be stored.
    What patch level are you using?
    Paul
    Edited by: pmackin on Sep 17, 2010 12:08 AM

  • Write-on/Write-off Vehicle

    Hi All,
      I am new to VMS..
      My Requirement ---write-off the vehicle. using  movement type and cost center...
      Is there any standard transaction available for Write-off/write-on...
      Please provide valuable Suggestion ..
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Oct 28, 2011 10:50 AM

    I am getting confused
    You and me both!!
    I am as certain as I can be that after doing my 702 write off there were no TOs or TRs created and the WM stock is sitting in the exact same storage type in LS26 as it was before I wrote off the stock and there doesn't appeart to be any other negative stocks in LS26 corresponding to my write off.
    I have discussed it further with the business and for the write-off issue, they are happy to write stock back on using a 701 movement and then write it off correctly using the 712 movements. e.g.
    Current
    WM 10
    IM    0
    701 Write On
    WM 10
    IM 10
    712 Write Off
    WM 0
    IM 0
    This will satisfy them for the write offs as from an IM point of view it will be a write on followed by a write off and from a WM point of view the stock will then leave correctly.
    However, we can not do the same thing for our stock that was wrote on as it has already been moved on from an IM point of view so the orginal question is still there. Is there a way we can write on stock from a WM point-of-view without updating the IM stock.

  • After system restore: why no more write permission with TM on TC?

    Hi.
    Last week I did a little mistake on my Macintosh HD by assigning user rights to all subfolders. I recognized my failure - but after confirming the warning advice...
    After that procedure (with a lot of failure advices) the system did not run any more. No problem - I'm using the 1TB time capsule and do have backups from the same day. So I restored my hole system by using the boot dvd and so on. Everything works fine so far.
    BUT:
    2 days later I recognized, that TM doesn't work since I restored my system. When I opened the TM configuration, it says that I need to asign a backup volume. OK - so I tried to asign the data file from the TC that I used before. I could see and confirm the file, but then there comes the advice (analogous):
    You don't have permission to write an that external network device.
    Log in as other user or contact your network administrator.
    I'M THE ADMIN!
    I tried all the hints I found in the web: repair the sparesbundle, reset TC, repair permissions in HD, create an new user with admin permissions,...
    Nothing helps.
    Only after I installed BatCHmod, chose the "old" data-file and marking the option "unlocking", TM works as before. The next backup needs a lot of time, because it backups the hole HD.
    Why did TM not work after the backup? How could it happen that there are major permission problems after using original Apple hard- and software?
    Why do I need a app from the web to run my system??
    Thanks so far,
    captain.nick

    sorry, t-mobile complete S
    null

  • Why does VISA write vi get a clock symbol added?

    In an application, I was using the older serial I/O primitive vi's, and now that I've switched to LV 7.1, I wanted to change the older serial read and write (worked fine) vi's (not VISAs) to the VISA Read and Write. When I place a VISA write on the block diagram, it adds a little clock symbol at the upper right corner that was not on the templates.
    What is this clock symbol doing there, when it wasn't on the functions panel version of the VISA write vi?
    Having a lot of problems getting the VISA read and write vi's to work; they seem to be far more tricky than the old primitive serial read and write vi's.
    All my VISA read vi's are getting errors, and some of them cause a severe slowdown on execution with those er
    rors. Thoughts on debugging these problemsome VISA vi's. (These problems are why I used the primitive serial read and write vi's in the first place.. couldn't get the VISA vis to work.)
    Thx.

    The little clock symbol means to do I/O asynchronously. If you right click on the function, you'll see the option to do it synchronously. Select that and the clock will disappear.
    What exactly are the errors that you're getting? One thing to try is to disable termination character detection with VISA Configure Serial Port and use VISA Bytes at Serial Port to determine how many bytes to read. If you have enabled the termination character and specify too many bytes to read, you'll get an error because VISA Read will timeout waiting for the termination character to be detected.

  • Why is the "Write" (new message) button greyed out? I can't write any new emails.

    Having trouble generating any new emails; The Write button in the toolbar is greyed out. Does anybody know why?

    Try to reset default.
    Right click on the Write button and select 'Customise'
    click on 'Restore default set' button.
    click on 'Done to close window.
    Please check to see if any addons are conflicting by restarting in Safe Mode.
    Help > Restart with addons disabled.
    If it works in TB Safe Mode then maybe an addon is causing a conflict.
    You would have to enable all addons - restart as normal and then gradually disable each in turn to see which one is the problem.
    Please post image of the top section showing all the toolbars and their buttons.

  • Why only 1 write speed available in Adobe Encore CS5.5?

    Hi,
    I am new to using my Encore in CS5.5. When trying my first project
    I only have 1 write Speed which is 6X. I want to write 2X. I have searched
    Forums & such with no answer that I can find. Help is appreciated.
    Thanks

    Create an ISO (Encore) or folder on your hard drive (Encore or Premiere Elements) and then use the FREE http://www.imgburn.com/index.php?act=download to write files or folders or ISO to disc (send the author a PayPal donation if you like his program)

  • Why i cant write my apple id while installing final cut prox updates? it's unclickable

    It's showing this error and i cant click at APPLE ID space to write my ID. Please HELP...

    com.microsoft.driver.MicrosoftMouseUSB    7.1
    com.microsoft.driver.MicrosoftMouse    7.1
    com.Cycling74.driver.Soundflower    1.6.6
    tc.tctechnologies.driver.PaeFireStudio    4.0.0 14255
    com.microsoft.driver.MicrosoftKeyboardUSB    7.1
    com.microsoft.driver.MicrosoftKeyboard    7.1
    Try removing the Soundflower driver first then restart your Mac.
    If that doesn't help, remove the PaefireStudio software, restart your Mac to test.
    FireStudio Family - How do I Uninstall & Reinstall my FireStudio drivers on a Mac computer?
    Beyond that try a different mouse and keyboard. If that helps, remove the Microsoft drivers.

  • Why we use write form,open form,close form,in script

    urgent

    Hi,
    OPEN_FORM
    The function module OPEN_FORM opens form printing. You must call this function module before you can use any other form function (WRITE_FORM, START_FORM, CONTROL_FORM...).
    You need not specify a form name. If you omit the name, you must use the function module START_FORM to open a form before starting the output.
    You must end form printing by using the function module CLOSE_FORM. Otherwise, the system does not print or display anything.
    Within a program, you can use several OPEN_FORM.. CLOSE_FORM pairs. This allows you to write output to several different spool requests from within one program.
    START_FORM
    In-between the function modules OPEN_FORM and CLOSE_FORM, you can use different forms. This allows you to combine several different forms into one print output. However, you can combine only those forms that have the same page format.
    To switch forms, use the function module START_FORM. If another form is still open, you must close it first using END_FORM.
    If you specify no form name when calling START_FORM, the system restarts the last open form. If after OPEN_FORM no form was activated yet, the system leaves the function module with the exception UNUSED.
    OPEN_FORM->
    To initialize the printing of forms via the Raw Data Interface, use function modules (OPEN_FORM und CLOSE_FORM) and a flag in the form (administration data). For this purpose, the function modules include the additional optional import parameter RAW_DATA_INTERFACE.
    http://help.sap.com/saphelp_nw04s/helpdata/en/d2/cb3d8e455611d189710000e8322d00/content.htm
    START_FORM->
    In-between the function modules OPEN_FORM and CLOSE_FORM, you can use different forms. This allows you to combine several different forms into one print output. However, you can combine only those forms that have the same page format.
    To switch forms, use the function module START_FORM. If another form is still open, you must close it first using END_FORM.
    If you specify no form name when calling START_FORM, the system restarts the last open form. If after OPEN_FORM no form was activated yet, the system leaves the function module with the exception UNUSED.
    from: http://help.sap.com/saphelp_nw2004s/helpdata/en/d6/0dba1a494511d182b70000e829fbfe/frameset
    Reward Points if found helpfull..
    Cheers,
    Chandra Sekhar.

Maybe you are looking for