Socket.close() on both sides?

Hello
i'm creating a server-client application, but i came at a problem:
i currently testing the logging out or disconnection.
The protocol does this: client sends packet to server with request for logout, server pushes response back and ?closes socket?, client reads response and ?closes socket?
now this is where i don't understand what i should do... should i close the socket on server side, or at client side ?
the thing is after the server received that packet, it sends packet back for confirmation and then unregisters the client, this means removing it from the client list (where it holds all clients for updating purposes at server side etc) and it closes its read/write thread, so stopping the thread from running. but should i also close the socket then?
or should i let the client close the socket? because while i send my packet of logout and receiving it, im also pinging (sending empty packet) the server to make sure the server is still online and server writes response back (this is a default operation, every 600ms), and when i close the socket on server side this will give offcourse an exception at clientside before i received the packet, so what should i do ??
Thanks in advnace!

You seem to have obfuscated what you actually want help with quite well,
this is my guess.
796870 wrote:
... or should i let the client close the socket?
because while i send my packet of logout and receiving it, im also pinging (sending empty packet) the server to make sure the server is still online and server writes response back (this is a default operation, every 600ms), and
when i close the socket on server side this will give offcourse an exception at client sideYour [url http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination]connection termination (wiki) results in RST.
before i received the packet, so what should i do ?For both server and client, when you are done sending data you use [url http://download.oracle.com/javase/6/docs/api/java/net/Socket.html#shutdownOutput%28%29]Socket.shutdownOutput() (javadoc).
EOS will result when the other party attempts to read() beyond the data available.
The other party can finish writing and use [url http://download.oracle.com/javase/6/docs/api/java/net/Socket.html#close%28%29]Socket.close() (javadoc) and
EOS will result when the first party attempts to read() beyond the data available.
The first party can then use [url http://download.oracle.com/javase/6/docs/api/java/net/Socket.html#close%28%29]Socket.close() (javadoc) which completes [url http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination]connection termination (wiki).

Similar Messages

  • Close tab button appears on both sides of tab and I couldn't find the option to fix it in the two addons I suspect of causing this: Tab Mix Plus & TreeStyle Tab

    After I switched to Tab Mix plus I started getting the close button on both sides of tabs which causes me to accidentally close them all the time.
    I also use TreeStyle Tab and I suspect an option in one of these two addons caused this... Or maybe a conflict?
    I tried to solve it myself through the addon options but to no luck.
    I'd like to keep both addons because they're great, help please?

    Try to ask advice at the Tab Mix Plus forum:
    *http://tmp.garyr.net/forum/viewforum.php?f=3

  • Java Socket Close Detection, Late FINs

    This is a wierd problem I have been facing.
    I understand that the only way that you can detect a remote client socket close(graceful only, NOT reset) in java is through reading (or writing )on a socket and detect IOException. For the final FIN/ACK the server should close the socket in the Exception handling.
    I have a server that currently does this in two ways. I read on the socket for a message on the socket.
    1. Using a DataInputStream (reads 2Bytes)
    2. Using a BufferedReader (reads a line)
    I have a client that opens n connections and closes them after 20 sec. I am doing 'netstat -al' to grep on the port to determine the status of connections on the server.
    Problem 1.
    When I am using BufferedReader, and open 100 connections to the server and close them (after 20 sec), I see that all the connections are closed in a matter of ms. (netstat -al| grep <portnum> shows no connections in CLOSE_WAIT). But on the other hand when I use DataInputStream some connections are lingering in CLOSE_WAIT for more than 20 seconds (this time increases with the number of connections).
    Why is this?
    Problem 2.
    The DataInputStream.read(2bytearray) does not throw IOException when I close the socket on the client side. It blocks till I close the connection on the client side. When the connection is closed the read succeeds. This to me is really wierd. Is this not a bug?
    I tried DataInputStream.readFully(2bytearray) and this works. This throws an Exception when the Client socket is closed.
    Any light on these issues is extremely appreciated.
    Thanks
    Subu

    Thanks for the response. That was a good point. I tried the BufferedInputStream also. This also does not seem really fast. For 100 connections it takes about 5 - 10 seconds. But even that is high. I dont think the server is a processing bottleneck. This is a production machine I am testing with. In any case I will do a top next to see that. (If 100 connections are high for the server, both the versions of the server should perform the sameway right)
    Thanks
    Subu

  • Using Brother printer, can't print on both sides.

    I installed OS 10.5 and now my printer is giving me almost no options other than just to print, including no option to print on both sides. Please help! Thanks.

    Thanks for providing that information Brisle .
    The software is installed by the Apple Updates. Unfortunately the two-sided feature will not work properly on Yosemite.
    Check the driver name that is installed for the printer. Make sure it shows just the printer's name.
    Click the Apple menu and then click System Preferences. Click Printers & Scanners, highlight the printer name on the left side and on the right side of the screen it should show the printer's name. (Laserjet P1102w)
    If the full printer name isn't listed correctly, delete it and add the printer name back in from the list. Click the - sign to delete the driver and then click the + sign to add the driver, might have to click the drop down to select the printer's name to add it in.
    I believe with Maverick and Yosemite, the software won't prompt you to flip the paper. The printer light will blink, if you open and close the cover though, it will continue to print. That is the only workaround at this time.
    I will check into this further. The Manual Duplexing Only Prints on One Side. Disregard the operating system.
    Sorry to have to be the bearer of bad news.
    Thank You.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • SMART FORM Both side printing

    Hi,
    I need help in printing smartform in both side. it has to print terms and conditions on back side of page after printing main window for each page.

    Hi Praveen,
    Try this logic!!!
    Create total 3 pages. For example
    Page 1 (items page)
    Page 2 & page 3 (terms & conditions)
    page1 (next page) = page2
    page2 (next page ) = page1
    page3 (next page) = blank
    Now In your main window in page 1, just after the table create a command and give next page as page3.
    I hope this will help you to close this thread.
    Appreciate if found helpful.
    Cheers!!!!
    Vinit
    Edited by: vinit005 on Mar 12, 2011 11:01 AM

  • Photosmart 7520 options issue: How to print black ink, on both sides, with borderless.

    I am checking to see if anyone has ever found a solution to the issue involved with borderless printing when the options "print on both sides" and "black ink only" are chosen.
    I used to be able to print on both sides, flip on long edge, and choose black ink only, and I was able to print borderless.  There was never an issue until last year, when out of the blue a yellow warning triangle appeared next to borderless printing.   I do not know why this happened, and I was never able to solve the issue, even with two hour-long conversations with polite and tireless HP phone reps.  One HP rep even helped me download a driver for a newer printer to see if that helped, and it did not.
    Now in order to print without the extra border, I have to do the following in order to receive the regular output:
    1.  After saving, I make a custom border that is .75 inches all the way around instead of one inch.
    2.  I increase the font size of every block of print by .5 in size.
    3.  Then I print, but I do not save;  when I close, it saves as it was before the changes I made to ameliorate the HP options mishap.
    If any HP technician our here can tell me when this issue will be addressed and solved, I would appreciate it. 
    Oh, I run an Acer laptop with Windows 7, the 64-bit version.  I use the wireless printing option.  This issue occurs with my Word Program (2013), and my up-to-date Adobe .pdf files. 
    Thank you very much.

    Hey there PrincessCupcake!
    Thanks for the detailed post back to me.
    If this was at one time an option for you and now is not, it would make sense to me that an update of some sort had made the option null and void for you, especially if you have completely uninstalled the printer driver and software and then reinstalled it. If the option was going to be available, doing the uninstall and reinstall would have fixed it in a jiffy.
    I am out of ideas as to any other cause besides an update, as you mentioned. If you have installed the printer on another computer, see if the options are there, if not, they aren't available.
    Happy Monday to you
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • HP Color Laserjet 2550n has no more printing on both sides

    In 2005, I bought an HP Color Laserjet 2550n to go with my laptop.  I had no printer problems.  I loved the feature where I could print a document on both sides of the paper.  The option would show up on the properties menu on the print document dialog window.
    Over the past summer, I lost my laptop to a crash and had to get a new laptop using Windows Vista OS.  I hooked up the printer using the USB port and all seemed good until I tried to print on both sides.  In the properties menu of the printing dialog box, the option has disappeared completely!  I tried updating the drivers - didn't fix it.  I tried reinstalling the software that came with the printer, but Windows Vista OS wouldn't accept it.  Help!  I don't know what else to do.  I appreciate any help.
    I have also tried Bob_Headrick's advice on Vista Duplex Printing Troubleshooting Guide for "No option for two-sided printing."  The option appeared in the properties menu, but the printer still did not print properly.
    Musicredsubaru
    Message Edited by musicredsubaru on 10-12-2009 08:18 PM

    Sorry guys................I answered my own question.
    I went into the HP P2015 user guide & found the answer. on page 32.
    I went into printer properties, device settings, noticed that duplex unit for printing on both sides was showing as "not installed". I changed this to "installed", and it worked.

  • I have 2 inches of empty space on both sides of the screen on all websites when using firefox. How do I get webpages to fill the screen?

    All my webpages on firefox have about 2 inches of empty space on both sides of the screen, but on Internet Explorer there is much less empty space or mostly none at all. How do i fix this?

    I can't make out from your low-res screenshot what those gray images in the menu at the left are, but I do not see them and there is nothing int the page source that accounts for them.
    *http://www.womensonlinebusiness.com/about-WomensOnlineBusiness.html
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Socket.close doesn't work in Windows browsers?

    I've been trying to figure this out for days and I can't seem to find anything on why this is happening or how to fix it.
    I have an FTP program written that uploads ByteArrays through sockets.  It works great on my Mac!  I open a command connection, then a data connection, send the ByteArray and then use socket.close() on my data connection.  This causes the server to disconnect me and sends the 226:transfer succeeded message back through my command connection.
    The problem is that in IE8, FF 3.5, and Safari 4 on Windows the socket.close() func does not make the server close the connection.  The fact that it works in all of my Mac browsers, and the IDE, but not in Windows browsers makes me think that it's something to do with the Flash Player.  Is this possible?
    My FP version check data:
    MAC 10,0,32,18
    WIN 10,0,32,18
    Does anyone know how I can fix, or even debug, this?

    does anyone have any idea what could be going on here?  am i completely out to lunch?

  • Regarding the Belkin Audio Splitter (3.5mm-M/2x3.5mm-F).  Are both sides of this splitter simultaneously bidirectional?

    Regarding the Belkin Audio Splitter (3.5mm-M/2x3.5mm-F).  Are both sides of this splitter simultaneously bidirectional?

    Direct connections are always best, but if you insist:
    Get a Griffin iTrip or replace your radio with one that has AUX inputs and/or Bluetooth.

  • How can i make a coppy both side with my hp 6500a plus all in one?

    how can i make a both sides coppy with my hp 6500A plus all-in-one?

    For windows:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c02773085&cc=us&dlc=en&lc=en&product=4083977&tmp...
    For MAC:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01935823&cc=us&dlc=en&lc=en&product=4083977&tmp...
    Although I am working on behalf of HP, I am speaking for myself and not for HP.
    Love Kudos! If you feel my post has helped you please click the White Kudos! Star just below my name : )
    If you feel my answer has fixed your problem please click 'Mark As Solution' and make it easier for others to find help quickly : )
    Happy Troubleshooting : )

  • Not sure if I sould put my InvisibleShield on both sides of the touch

    I've already gotten my full-body invisible shield thing, and yesterday I ordered a touch.
    In some discussion someone said that it's better to put the IS only on the back side of the touch because the when you put it on the screen it reduces its quality.
    But on the other hand, I saw this topic: http://discussions.apple.com/thread.jspa?threadID=1174180&tstart=15
    And I really don't want my touch gettin' scratched like it happened to this one.
    So if I already have a full-body InvisibleShield, should I put it on both sides or just the back?
    And is it possible to remove the front shield without it leaving any "marks"?

    I've just put mine on my iPod Touch. Only the back one though. Have a look here for what I've posted.
    http://discussions.apple.com/thread.jspa?threadID=1160153&start=120&tstart=0
    Hope this helps.
    Chris

  • How do I print to both sides of paper for greeting card on Brother Printer

    I did not find the answer on the forum. I have iLife 09 and this Brother MFC-790CW printer. I do not see any automatic setting for printing on both sides. I am using a iPhoto greeting card template and it looks OK with a page one for the front and a page two for the back.
    Maybe the only way is to print out all the fronts pages (20) and then put the paper back in and print all the pages 2 (the text inside of the card). That seems like it would be faster than other ways, except automatic.
    Obviously I should have done this a month ago and sent the project to Apple, but now I have no more time. Ii have the right paper for the one fold cards and plenty of ink

    You need to have an image editor that supports layers. If you do follow the directions in these tutorials:
    #8 - Printing a iPhoto Greeting Card
    #8a - Printing a iPhoto Greeting Card to Standard Stock Sizes
    Here are some editors that support layers:
    Some Image Editors that support layers:
    Photoshop Elements 8 for Mac - $79
    GraphicConverter - $45
    Rainbow Painter - $30
    Acorn - $50
    Pixelmator - $60
    Seashore - Free
    Portraits and Prints - Free
    GIMP for Mac - Free
    You might be able to use Pages instead of an image editor.
    Happy Holidays

  • TS1292 Purchased gift cards about a year ago. Misplaced two of them. Found them yesterday, tried to use one today. Invalid. If the money is tagged to the card code why is it invalid? Now have to take photos of both sides and find receipt? Guess out $20?

    Purchased gift cards about a year ago. Misplaced two of them, but Found them yesterday. i tried to use one today. Invalid. If the money is tagged to the card code why is it invalid? Now have to take photos of both sides and find receipt? Finding the receipt might take as long as .finding the cards. If I paid hard earned money for the card from a computer company why would that card not be in their data base waiting to be activated? I guess I am out $20 to Apple for not activating immediately! My account was hacked once so I won't put a credit card in and live with gift cards. Now I am getting hit for $20, two gift cards for ten each. I now question who and how people are making money?? Is my only solution, buy card, redeem code instantly, purchase item?

    Hi Oxfordataloss,
    Thanks for posting. I'm really sorry you've had such problems with BT, it's certainly not the kind of service we would hope to provide. I'll take your comments on board and if you don't receive the final bill as expected please drop me an email with the account details and a link to this thread for reference.
    Cheers
    David
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • Is there any way to create a shadow in both sides of a box?

    Hi,
    is there any way to create a shadow in both sides (opposite) of a box? I just can create the shadow in one side..
    If not, is that possible in CS6?
    CS5.
    Regards

    You can definitely show an inner shadow on just one side of a rectangle.  You just need to turn the blur down to 0 to prevent it from leaking to the nearby sides.  Then set the angle to an exact multiple of 90, like 270 to put the shadow on the top side of the rect.
    This file has some examples: http://johndunning.com/fireworks/scratch/Shadowed%20Elements.png
    If you're trying to simulate a rectangle with different border colors or widths, this auto shape can make that easy: http://johndunning.com/fireworks/about/MultiBorderRect

Maybe you are looking for

  • How to move a file from one internal drive to another

    I have a Mac Pro with 10.6. My main drive is a 240 GB SSD. I would like to move files from it to another internal drive to free up space on the SSD. The only way I can figure out to do it is to copy a file to the other internal drive and then move it

  • HT2186 Is it possible to download Snow Leopard?

    Currently I have OS X 10.5.8 (leopard). I can't access the App Store until I have Snow Leopard, and I can't have Snow Leopard shipped because I work in Iraq... I would really appreciate any help you might be able to offer me. Best, Chris

  • No sensor detected?

    wenever i would start i workout i would select a playlist and it would never work it would say "no sensor detected" help??

  • Lightroom loses import source after few seconds?

    I have lightroom version 4.2 running on Windows 7. When I import images, if I spend too long slecting the images I want to import from my memory card, the Import source is lost and all my selections are lost. It is driving me roudn the bend! Is there

  • X201i Win XP SP3 Blue Screen on Death

    Dear Support Team,  I have a problem for my X201i. I'm use Win XP SP3 for this notebook. the Bluetooth application is not active and I try to restart and go to bios mode for enable Bluetooth using F9 (set bios default) and restart again. and the prob