Java客户端/服务器通信,我需要学习什么

时间:2022-08-26 19:54:03

I'm new to Java Networking (not Java), I trying to develop a client application that connect to a server, so the server can receive database table and store them online, activate the application: when the user enter activation information, the application connect to the server, send those information, and then the server reply. what I need to know is what technologies/classes can acheive this?? what I need to learn?? is it Java RMI or {InetAdress, URL/URI, URLConnection, Socket, ServerSocket, UDP..} Stuff or what exaclty ??

我是Java Networking(不是Java)的新手,我试图开发一个连接到服务器的客户端应用程序,因此服务器可以接收数据库表并在线存储它们,激活应用程序:当用户输入激活信息时,应用程序连接到服务器,发送这些信息,然后服务器回复。我需要知道的是什么技术/类可以实现这一点?我需要学习什么?是Java RMI还是{InetAdress,URL / URI,URLConnection,Socket,ServerSocket,UDP ..}什么东西或什么exaclty?

I'm currently reading Java Network Programming, Elliotte Rusty Harold, is this what I need to learn??

我目前正在阅读Java网络编程,Elliotte Rusty Harold,这是我需要学习的内容吗?

I developed a JavaFX 8 application and it's out there, it's free, now I'm trying to develop a payed version, and one of the thing I will add is client/server communication. Thanks a lot

我开发了一个JavaFX 8应用程序,它就在那里,它是免费的,现在我正在尝试开发一个付费版本,我将添加的一个东西是客户端/服务器通信。非常感谢

1 个解决方案

#1


3  

what I need to know is what technologies/classes can achieve this?? what I need to learn?? is it Java RMI or {InetAdress, URL/URI, URLConnection, Socket, ServerSocket, UDP..} Stuff or what exactly ??

我需要知道的是什么技术/类可以实现这个?我需要学习什么?是Java RMI还是{InetAdress,URL / URI,URLConnection,Socket,ServerSocket,UDP ..}东西或究竟是什么?

As per the given requirement, it'd be enough for you to learn coding with Java Socket Programming. You don't need a URL/URI unless you're going to connect it to the internet.

根据给定的要求,使用Java Socket Programming学习编码就足够了。除非您要将其连接到互联网,否则您不需要URL / URI。

And, you should start with sockets/server-sockets, then TCP/UDP is easy to decide based upon the requirement of the application. If the data is critical, you should go for TCP, which is slower as compared to UDP, which in fact doesn't guarantee the packets will arrive in order, or, even if they'd arrive or not. So, you could go with DatagramSocket/Packet OR normal Socket based on whether you use UDP/TCP.

而且,您应该从套接字/服务器套接字开始,然后根据应用程序的要求轻松决定TCP / UDP。如果数据很关键,那么你应该选择TCP,这比UDP要慢,实际上并不能保证数据包按顺序到达,或者即使它们到达也没有。因此,根据您是否使用UDP / TCP,您可以使用DatagramSocket / Packet或普通Socket。

Talking about Java RMI, that is a way too old technology. But, it is good to know this technology. That technology could be used to implement distributed application programming, so obviously you can achieve even the Client-Server communication with that. But, that's somewhat imprecise to use RMI for such an easy task.

谈论Java RMI,这是一种过于陈旧的技术。但是,了解这项技术是件好事。该技术可用于实现分布式应用程序编程,因此显然您甚至可以实现与客户端 - 服务器的通信。但是,使用RMI进行如此简单的任务有点不精确。

My personal suggestion --- Learn some basic networking with the book mentioned below by the author Esmond Pitt, who is among us even here as a fellow member of this community.

我的个人建议---通过作者Esmond Pitt在下面提到的书中学习一些基本的网络,我们甚至在这里作为这个社区的成员。

I'm currently reading Java Network Programming, Elliotte Rusty Harold, is this what I need to learn??

我目前正在阅读Java网络编程,Elliotte Rusty Harold,这是我需要学习的内容吗?

I also started learning Java Network programming with the same book,but, the author has made the book too complex for a beginner.It is OK to continue if you want to make a career in Java Network Programming. If not, then you should start with some easier text book like Fundamental Networking in Java, though this book is somewhat outdated and still revolves around JDK 1.5 as no new publishing has been done for this book after 2006. That is an easier to read book, and even the author of the book(EJP) is active here on Stack Overflow. You shouldn't get dumbstrucked if he answers your questions here. BTW, I got to know about his books very recently and I enjoyed having a review of that book.

我也开始用同一本书学习Java网络编程,但是,作者对于初学者来说这本书太复杂了。如果你想在Java网络编程中工作,可以继续。如果没有,那么你应该从一些更简单的教科书开始,比如Java中的基础网络,虽然这本书有点过时,但仍然围绕着JDK 1.5,因为在2006年之后没有为这本书做过新的出版。这是一本更容易阅读的书甚至本书的作者(EJP)也在Stack Overflow上活跃。如果他在这里回答你的问题,你不应该傻瓜。顺便说一句,我最近了解了他的书,我很高兴看到那本书。

#1


3  

what I need to know is what technologies/classes can achieve this?? what I need to learn?? is it Java RMI or {InetAdress, URL/URI, URLConnection, Socket, ServerSocket, UDP..} Stuff or what exactly ??

我需要知道的是什么技术/类可以实现这个?我需要学习什么?是Java RMI还是{InetAdress,URL / URI,URLConnection,Socket,ServerSocket,UDP ..}东西或究竟是什么?

As per the given requirement, it'd be enough for you to learn coding with Java Socket Programming. You don't need a URL/URI unless you're going to connect it to the internet.

根据给定的要求,使用Java Socket Programming学习编码就足够了。除非您要将其连接到互联网,否则您不需要URL / URI。

And, you should start with sockets/server-sockets, then TCP/UDP is easy to decide based upon the requirement of the application. If the data is critical, you should go for TCP, which is slower as compared to UDP, which in fact doesn't guarantee the packets will arrive in order, or, even if they'd arrive or not. So, you could go with DatagramSocket/Packet OR normal Socket based on whether you use UDP/TCP.

而且,您应该从套接字/服务器套接字开始,然后根据应用程序的要求轻松决定TCP / UDP。如果数据很关键,那么你应该选择TCP,这比UDP要慢,实际上并不能保证数据包按顺序到达,或者即使它们到达也没有。因此,根据您是否使用UDP / TCP,您可以使用DatagramSocket / Packet或普通Socket。

Talking about Java RMI, that is a way too old technology. But, it is good to know this technology. That technology could be used to implement distributed application programming, so obviously you can achieve even the Client-Server communication with that. But, that's somewhat imprecise to use RMI for such an easy task.

谈论Java RMI,这是一种过于陈旧的技术。但是,了解这项技术是件好事。该技术可用于实现分布式应用程序编程,因此显然您甚至可以实现与客户端 - 服务器的通信。但是,使用RMI进行如此简单的任务有点不精确。

My personal suggestion --- Learn some basic networking with the book mentioned below by the author Esmond Pitt, who is among us even here as a fellow member of this community.

我的个人建议---通过作者Esmond Pitt在下面提到的书中学习一些基本的网络,我们甚至在这里作为这个社区的成员。

I'm currently reading Java Network Programming, Elliotte Rusty Harold, is this what I need to learn??

我目前正在阅读Java网络编程,Elliotte Rusty Harold,这是我需要学习的内容吗?

I also started learning Java Network programming with the same book,but, the author has made the book too complex for a beginner.It is OK to continue if you want to make a career in Java Network Programming. If not, then you should start with some easier text book like Fundamental Networking in Java, though this book is somewhat outdated and still revolves around JDK 1.5 as no new publishing has been done for this book after 2006. That is an easier to read book, and even the author of the book(EJP) is active here on Stack Overflow. You shouldn't get dumbstrucked if he answers your questions here. BTW, I got to know about his books very recently and I enjoyed having a review of that book.

我也开始用同一本书学习Java网络编程,但是,作者对于初学者来说这本书太复杂了。如果你想在Java网络编程中工作,可以继续。如果没有,那么你应该从一些更简单的教科书开始,比如Java中的基础网络,虽然这本书有点过时,但仍然围绕着JDK 1.5,因为在2006年之后没有为这本书做过新的出版。这是一本更容易阅读的书甚至本书的作者(EJP)也在Stack Overflow上活跃。如果他在这里回答你的问题,你不应该傻瓜。顺便说一句,我最近了解了他的书,我很高兴看到那本书。