I have a client and a server application where the client sends a byte of data that signals that the user has closed the client window and terminated the client program. The problem is that the server may send one last notification to that client before discarding him. If the server uses the SocketChannel's write method in blocking mode is it going to block indefinitely or is it simply ignored? Should I make the client wait for a "disconnection acknowledgement" before it is disconnected?
Sending data to a client through a SocketChannel after he has closed his
292 Views Asked by Bat0u89 At
2
There are 2 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in CLIENT-SERVER
- Python socket stays blocked on socket.recv() when client expects data
- How to test java server without deployment?
- Client/server: running "nano editor" command from client
- Client/Server java - connection refused
- ZeroMQ Job Distribution
- Multithreading using Blocking IO corrupts file in Java
- Use Photoshop actions on the server
- difference between p2p and client-server node design
- Android | can't Send/Receive message to/from Wialon Server using Socket
- Raising alerts from backend javascript
- How do I send a Javascript/CSS file that corresponds to the HTML document in HTTP?
- What is Starbucks populating the URL with when I login?
- When can be socket client disconnected
- Janrain mobile integration using RESTFul API? for Windows, iOS and Andorid
- HTML-service pages to call server-side Apps Script functions with dialog box
Related Questions in SOCKETCHANNEL
- Java WindowsSelectorImpl totalChannels
- java.lang.IllegalThreadStateException: Thread already started error when using selectors with SocketChannel
- Can I access SocketChannel from ChannelHandlerContext in Netty?
- how to register multiple SocketChannel on one thread with a Selector on different thread
- which method is better for network communication using java.net or java.nio for Android applications
- ServerSocketChannel to accept more connections from the same client
- SelectionKey with empty interest set
- SocketChannelImpl.write(ByteBuffer[] srcs, int offset, int length) appends ByteBuffer of size 0
- Java NIO: How to know when SocketChannel read() is complete with non-blocking I/O
- One thread stopping too early regardless of CyclicBarrier
- Java trouble with SocketChannel connections
- How to send parameter values to server using Socketchannel?
- Java: how to reuse SocketChannel
- Java.nio Channels and TLS
- msgpack-java & java.nio.SocketChannel
Related Questions in DISCONNECTION
- BLE CC2541 disconnect with the app after some time
- Why does my telegram bot unset webhooks when I send it a text
- Unexpected disconnection for users on Chrome with my wordpress website
- Difference between unplugging ethernet cable and disabling ethernet network from OS
- Detecting Socket disconnect
- Is there an application to block access to a remote machine (to simulate a disconnection)?
- Sending data to a client through a SocketChannel after he has closed his
- Android Bluetooth Low Energy connection timeout while BLE chip is computing
- Android SIP - How disconnect from SIP Server
- Network stream no longer works after connection loss
- ASIHTTPRequest no error when lost connection
- Android Bluetooth Peripheral: Connection terminated by peer (Status 19)
- Periodic client disconnections in MQTT NodeJS server on websockets when deployed to Google Cloud Run
- Socket connection between end points on the same machine
- Database connection with postgres keeps on disconnecting in the server in python language
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It won't block forever and it is not ignored. It is quite possible that it won't block at all, if there is room in the socket send buffer for the data. If it does block it may incur an IOException: 'connection reset by peer', or it may just unblock and return normally. There is no predicting this. The situation is incorrect and should not be allowed to occur. You can get to an agreed mutual close point by shutting down both sockets for output and then reading until you get an EOS; then both sides are at the same point and may close.