When I use the java socket

Asked 2 years ago, Updated 2 years ago, 27 views

You know how you connect the socket with a try door

And send receive and send text messages to each other

It's natural that it's still available in the try statement, but I want to send it when I click the button, but I can't call up the sender receive function, but I can connect it again, but how do I usually use it? Static It's not possible, and I'm curious how it's usually done

java

2022-09-22 20:28

1 Answers

The reason why the socket is difficult to handle is that the minimum multi-thread must be considered.

Blocking is basically a multi-threaded environment.

At this point, one thread works by checking the buffer reception with infinite repetition. Sending is called per event, and receiving creates a separate thread and treats it as an infinite loop.

This is a simple way to handle blocking sockets.

However, multi-threads can be a difficult topic, so prior learning is necessary.


2022-09-22 20:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.