logo
down
shadow

how can i make this dialog close when socket is accepted?


how can i make this dialog close when socket is accepted?

By : Rahul Desai
Date : November 22 2020, 02:59 PM
seems to work fine Your server socket code's variables are very tough to read, I have named it in general way in the below code(adjust accordingly). You need to write a method written below as closeDialog() [or give a better name]; and call the constructor first, then this method and it'd close the JDialog.
Also, you need to extend the scope of your JDialog upto the class, instead of the method waitConnection() by declaring it in the class scope.
code :
public class Server
{
private ServerSocket serverSocket;

public Server(int port) throws IOException
{
  serverSocket = new ServerSocket(port);
  // optional timeout part depending on your application.
  serverSocket.setSoTimeout(10000);
}

public closeDialog(){
try{
Socket server = serverSocket.accept();
dialog.dispose();
// Rest of your code
}
catch(SocketTimeoutException s)
     {
        System.out.println("Socket timed out!");
     }catch(IOException e)
     {
        e.printStackTrace();
     }
  }
// Rest of your code
}


Share : facebook icon twitter icon
Java ServerSocket won't accept new connections until close() is called on the accepted socket

Java ServerSocket won't accept new connections until close() is called on the accepted socket


By : Adroit
Date : March 29 2020, 07:55 AM
I hope this helps . Obviously the problem is not here but in the MatchThread class whose code you haven't posted. It appears you have a single thread dealing with that queue. Why?
why netty can not make a distinction between socket close and socket half close

why netty can not make a distinction between socket close and socket half close


By : Kackefahrer
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Nobody can tell the difference. Shutdown for output sends a FIN. Close sends a FIN, unless it has already been sent, i.e. by a shutdown. FIN appears at the receiver as the EOS (EOF) condition. The server got the FIN from the shutdown, saw that as EOS, closed the socket, your client got the FIN, saw that as EOS, closed the socket, and sent ... nothing to the server, because the FIN had already been sent.
android can't close dialog when run socket

android can't close dialog when run socket


By : Bjoern R.
Date : March 29 2020, 07:55 AM
help you fix your problem You need to change your code to start a Thread, You need to call the method start() - that will execute the run() method written in that Thread.
So, Invoke Connect.start() instead of Connect.run() inside your onClick handler.
Close Alert Dialog Builder when File is Received via Socket

Close Alert Dialog Builder when File is Received via Socket


By : kgecdeep
Date : March 29 2020, 07:55 AM
around this issue dele is an instance of AlertDialog.Builder. grab the dialog when you call .show() then dismiss it.
Read this too
How to make an accepted socket non-blocking in java

How to make an accepted socket non-blocking in java


By : user3816318
Date : March 29 2020, 07:55 AM
Any of those help Two things:
Why aren't you using a ServerSocket if you're listening for connections? If you want to accept multiple clients you want to use a loop.
Related Posts Related Posts :
  • How can I get a Class object form primitive?
  • How to count rows and Columns of excel sheet in Java
  • Should I split up texture atlas?
  • JavaFX freezing issue
  • What is the JavaFX equivalent of androids AsyncTask?
  • Zenity bash command not working with Java
  • GSON serialize multiple properties to sub object
  • How to convert some elements that satisfy a particular condition in a 2d array into a list in java?
  • Setting LinkedList nodes to null
  • Java Swing ignore text size on JButton
  • Collision detection for separate class instances - Processing Java
  • handle unreal numbers, jump to catch
  • Java - 100 decimal places in variable
  • Cancel previously shown toast before showing new toast
  • projectile motion sim - 'illegal start of type' error
  • How to print out the whole contents of a stack?
  • How to find variable name from a list of class in a package
  • I have created a small book program, I am new to java. Can't find what the error or mistake in this code?
  • How to get a variable from a php file and use it in a Android activity?
  • Creating an updater. Updating/downloading part
  • How can i print my array and my histogram on the same line?
  • Unknown error on if, else if, else statement
  • WebView crashing
  • Compare formatted dates to integers in Java
  • java sudoku why it doesnt show me the final result of sudoku
  • Json referring font to different font error
  • High-accuracy time syncing between Android (Java) and .NET DateTime?
  • Maven environment mac
  • What are these mystery characters
  • What is the proper way to say `#` to other developers?
  • How to make a Model attribute global?
  • Spring REST returning PDF - Response status 406 (not acceptable)
  • Unable to Resume Activity: Null Pointer Exception on button click
  • Android ListView Adapter returns NullPointerException
  • Android Audio fingerprinting implementation
  • Using comparator with poker hands: error with compare method
  • Differentiating between no input (null String) and Cancel button in JOptionPane.showInputDialog()?
  • error: package com.bea.core.repackaged.springframework.util does not exist
  • IntelliJ structural search generics
  • Uploading files to REST from java side works, from python not
  • Compiling generated code and jar with JavaCompiler
  • compress file with GZIP in java
  • Add one to a number stored in a digit array
  • Serialization for Java Calendar
  • How to install Jcalender in Eclipse?
  • Build Failed, Missing Key Attribute (Android SDK)
  • Guess Number Game in Java
  • Ascending Order Bubble sort java.lang.ArrayIndexOutOfBoundsException: 5 at wst2.calc(wst2.java:18)
  • PhantomJS & Conductor Framework
  • How does the PCFMessageAgent handle disconnecting?
  • Shiro Session Clustering with Hazelcast, not on the Web
  • InputStream or Reader. Method with same logic
  • Struts 1.2 decrease float precision in <bean:write> tag
  • My script is not creating new row after last filled row
  • Building JDK 8 sources with Eclipse
  • How to deal with visualization of java.util.Date with a custom timezone in JSF
  • Why am I getting an IllegalFormatConversionException?
  • Error adding timestamp to log file name (log4j2)
  • Generate a single .jar with only androidTest code
  • getWindowHandles return one window handle if multiple tabs are open in single window
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co