是否总是有必要编写服务器程序来监听我们的客户端程序 [英] Is it always necessary to write a Server Program to listen to our client programs
问题描述
我刚刚开始学习Linux上的C语言中的Socket编程,并且在开头的任何教程中看到的第一句话都是编写客户端和服务器程序".出于好奇,我想知道是否总是强制将Server程序显式写入到我的程序中,称为Client.
例如:假设说过一段时间后,我想编写一个程序,该程序实际上提供了连接到特定系统(Server)的GUI.我的意思是,我以GUI方式显示该特定系统的文件和文件夹.因此,我是否需要在服务器端显式编写一些程序以实现此目的,或者如果可以通过编写的客户端程序实现相同的目的,那还可以吗?
请提供您的宝贵建议.
问候
Hi ,
I have just started learning Socket programming in C on Linux and the first sentence i see on any tutorial in the beginning is "Writing Client and Server Programs". Out of my curiosity i would like to know that if is it always compulsory that Server programs to be explicitly written to my program called as Client.
Ex: Suppose say that after a while i would like to write a program which infact provides a GUI in connecting to a particular System ( Server ). I mean, i display the files and folders of that particular system in a GUI fashion. So do i need to write explicitly some program on the Server side to achieve this or if it is ok if the same can be achieved through a client program written.
Please provide your valuable suggestions.
Regards,
推荐答案
客户端"和服务器"是逻辑术语. 服务器"是响应请求的内容,因此,如果您希望响应请求,则需要系统的这一部分.
在所有连接的客户端期间,服务器代码或程序都是必需的.
将服务器代码放在一个客户端中,而将其他客户端连接到该客户端代码(例如对等应用程序),就完全可以了.
"Client" and "Server" are logical terms. A "Server" is something that responds to request, so if you want your request to be responded to you need this part of the system.
Server code or programs are required for the duration of all the clients connected.
You are perfectly fine in having the server code in one client, and the other clients connecting to it (like peer to peer applications).
简单地说,服务器根据请求提供数据.
客户端以适当的方式显示此数据.
要求时,HTML服务器为网页提供html源.
客户端程序可能会以其认为合适的任何方式显示此内容-它可能:禁用图像显示,解析和跟踪链接,然后再检查链接是否位于黑名单上的站点,更改字体大小和颜色以使可读性更易于禁用用户,等等.
只要服务器可以向您发送请求的必要信息(文件名,大小,数据,权限等),然后您就可以选择将其显示为文本格式的目录,就像DOS一样显示在目录中,或者在资源管理器类型的窗口中就像Windows一样或您选择的任何其他方式.
总结一下,只要服务器可以提供所需的信息,您就可以编写一千个(或者更多,如果愿意的话)不同的客户端程序,以任何您喜欢的方式显示此信息.
您可以在客户端程序中实现您的功能.
Simply put, the server provides the data upon request.
The client displays this data in the appropriate fashion.
A html server provides html-source for web-pages when requested.
A client program may display this in any way it sees fit - It may: disable display of images, parse and follow links before checking if the link is on a black-listed site, change the font size and colour to make readability easier for disabled users, and so on.
As long as the server can send you the requested and necessary information - file name, size, data, permissions, etc - you can then choose to display this as a text-format directory listing as DOS does, or in an explorer-type window as windows does or in any other way you choose.
Summing up, as long as the server can provide the required information, you can write a thousand(or more if so inclined) different client programs that display this information in whatever way you like.
Your functionality can be achieved in the client program.
您必须先运行某些服务器程序来接受连接请求,然后才能连接到服务器系统.话虽这么说,有许多知名端口 [
You cannot connect to a server system without some server program running to accept your connection request. That being said there are a number of well known ports[^] that you may be able to connect to if their service programs are enabled on the server system. Examples are FTP, TCP, HTTP etc.
这篇关于是否总是有必要编写服务器程序来监听我们的客户端程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!