A
A
Amuser2018-05-20 13:24:40
Java
Amuser, 2018-05-20 13:24:40

Does Socket.Accept() freeze the program?

I'm trying to make a client-server in java via Socket, let's say there are two buttons in the frame, one starts the server, the second connects the client, I press the first one, on accept() the program freezes and starts waiting for the client (buttons do not press, keyEvent does not work), Accordingly, I can not connect the client, how to deal with this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-05-20
@Amuser

accept is a blocking call. Blocking calls must be performed in a separate thread.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question