Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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,
Posted

"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).
 
Share this answer
 
Comments
Albert Holguin 13-Sep-11 13:12pm    
Pretty much it... +5
Mehdi Gholam 13-Sep-11 13:16pm    
Cheers
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.
 
Share this answer
 
Comments
Albert Holguin 13-Sep-11 13:14pm    
yep, gave you a +4 simply because mehdi's solution also adds the fact that you can really even add all the implementation into one application (server/client), although that's not the typical case for most applications.
enhzflep 13-Sep-11 13:41pm    
Thanks Albert.
A good point that both Mehdi and yourself you make about ability to roll server/client into a single app. :thumbs-up:
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.
 
Share this answer
 
Comments
[no name] 13-Sep-11 10:45am    
Okay...So if on my Server system Sevices like FTP or TCP etc., are enabled then i need not write explicit server program to list the remote directory in my client's program. In this regds i am talking at a very higher level for an understanding. Am i Correct ?
Richard MacCutchan 13-Sep-11 11:08am    
If you use TCP or FTP for example (assuming they are enabled), then you must abide by their protocols to get the information you want. I think the issue is really one of "what problem are you trying to solve", rather than whether you should write your own server program. The answer to the first question should lead you to the answer of the second one.

Albert Holguin 13-Sep-11 13:11pm    
Well, the services your listed are "server" programs... that someone already wrote. So technically, you always need a server, although as listed in another solution, it doesn't necessarily have to be a different program.
Richard MacCutchan 13-Sep-11 13:24pm    
That's what I said.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900