CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2008
    Posts
    6

    Unhappy Socket Programming and FTP

    Hello Everybody

    I am a newbie in FTP or socket programing, I have designed an application to transfter data using both Socket and FTP in C++( Visual Studio).

    What I would like to know is, Are there any advantages of using Socket programing over FTP?

    I know FTP is a protocol which using TCP internally, similarly Socket also has two kinds of protocol associated with it, UDP and TCP depending on what you pick to send your data.

    It is my understanding that Sockets are basically used to send data to another computer over a smaller network without having to set up a seperate machine as server.

    In case of FTP, We have to have a dedicated machine as FTP server( we have to setup an FTP server right?) which has to be set up for any client program to access it, setting up an FTP server is not like writing a server program using TCP or is it ?

    Another thing that is bothering me is, FTP server whether active or passive uses Port 21 ( command port) for the data transfer, so would that mean that at any time there can be only one FTP client connect to the server, whereas in Socket there can be lots of socket connecting to the server at the same time ?

    I know these questions are basic, but there is not really a topic that tells that when using the sockets or FTP in our application what are the differnce, Kindly let me know what are the points i missed.

    Kindly pardon me for my typos and bad english

    Regards
    Kittu

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Socket Programming and FTP

    You've misunderstood some things here. Sockets are the lower layer in all network communications. On top of that layer there are many protocols such as FTP, HTTP, SCP, SMTP, IRC and on and on... If you go for raw socket communication instead of using FTP then you have to design and implement your own protocol. This can be an easy or an overwhelming task depending on your needs.

    To establish a TCP socket connection you always have to have a machine that is a server that accepts the client to be connected. Without the server accepting the connection the client can't send anything.

    An UDP socket is a connectionless communication. The "talker" just sends a package hoping that the reciever is listening. If the reciever is listening or not the sender will never know.

    Regarding passive & active FTP here's an explaination http://www.slacksite.com/other/ftp.html As you can see neither active nor passive mode FTP put any restraints in number of active sessions.
    Last edited by S_M_A; April 6th, 2008 at 07:22 AM.

  3. #3
    Join Date
    Apr 2008
    Posts
    6

    Re: Socket Programming and FTP

    Thank you for your reply.


    I am sorry I think i framed my question wrongly.

    Well when i am creating a socket, I am using Winsock, so all i do is create a socket and windows uses it to create raw TCP sockdets and send the data.
    I dont implement any of the protocol, Windows does it for me.

    So when it comes to applicatons using Winsock for sending data, and using FTP for sending data? What is the difference, if there is no difference why we have two differnt kind of data transmission

    Can you explain how to write an FTP server ?

    thanks once again, I am just a newbie thats why I am so many questions

  4. #4
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Socket Programming and FTP

    As explained by SMA, one is more basic than the other, in the sense that sockets are "closer to the network". FTP uses sockets for its network communications. So does HTTP and SMTP and SNMP and NNTP etc. You can think of sockets as a protocol at the "network" level (or layer), and the other protocols at the "application" level. FTP and all the others are application-level protocols built on top of the network-level protocol provided by sockets.

    Sockets is an API that allows you to program using the two main varieties of network-level protocols, TCP and UDP.

    At the network level, data is just bytes of data. The data has no meaning. It's just binary data, with no interpretation given to it. That's the beauty of the layered approach: at the network level, the data is abstract data that just needs a transport from one endpoint to another. Someone else is responsible for interpreting and giving meaning to the data, once it reaches an endpoint.

    The application layer is the thing responsible for giving meaning to data. In FTP, for example, there are commands that are exchanged, in order to prompt the exchange of file data. The network layer doesn't care about the content of those commands: it's just data. The FTP layer gets the data from the network layer, and then the FTP layer is the thing responsible for interpreting the data and determining which commands were sent.

    Read here: "The five-layer TCP/IP model" at http://en.wikipedia.org/wiki/TCP/IP_model

    Mike

  5. #5
    Join Date
    Apr 2008
    Posts
    6

    Re: Socket Programming and FTP

    Thanks Mike,
    I think now i get what you and SMA are telling me. If i hav emore ?s i will come back and bug you

    thanks guys

    Kittu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured