我可以运行这样的服务器/客户端程序吗?
我想写一篇雅虎! Messenger 和我创建了 2 个 Java 应用程序。一个用于“服务器”,另一个用于“客户端”。首先我运行服务器应用程序,然后我将运行客户端应用程序中的 GUI 框架(所以我将运行我的客户端应用程序):它将显示一个从客户端获取用户名和密码的框架。如果用户名和密码正确,我将调用在 ClientNetwork 包中的客户端类中创建它的方法(该包位于客户端应用程序中)。 这是运行该程序的正确方法吗?
I want to write a yahoo! messenger and I create 2 java applications .one is for "server" and the other one is for" client" .at first I run the Server application and then I will run my GUI frame which is in my client application(So I will run my client application):it will show a frame that gets user name and password from a client . IF the user name and password were correct I will call the method which I create it in my client class which is in my ClientNetwork package(this package is in Client application).
Is this a correct way to run this program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要确定用于在两个程序之间进行通信的某种协议。此外,您很可能需要它通过 TCP/IP 工作。
我建议您研究客户端/服务器编程。以下是相关的 Sun Java 教程页面 - http://java.sun。 com/docs/books/tutorial/networking/sockets/
You will need to determine SOME protocol that will be used to communicate between the two programs. Also you most likely need it to be working over TCP/IP.
I would suggest you look into client/server programming. Here is the relevant Sun Java Tutorial page - http://java.sun.com/docs/books/tutorial/networking/sockets/
另请注意,用户名和密码检查应在服务器上完成。从您的问题来看,并不清楚在哪里检查凭据,但重要的是不要在客户端执行此操作。
在客户端执行的任何操作都可能受到损害,并且您当然不希望恶意用户能够使用其他人的名称登录。
Also note that the username and password check should be done at the server. It wasn't quite clear from your question where the credentials are checked, but it's crucial not to do it at the client.
Anything that's done at the client can be potentially compromised, and you certainly don't want a malicious user to be able to log in with someone else's name.