Using sockets by the fstream interface

This is a discussion on Using sockets by the fstream interface within the C++ Programming forums, part of the General Programming Boards category; When modifying an old application making use of sockets I found that I had used the old c-style function to ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    3

    Using sockets by the fstream interface

    When modifying an old application making use of sockets I found that I had used the old c-style function to handle the transmissions. I therefore constructed a class to handle this wrapping those methods in other to simplify my work, although I soon found this was ugly and therefor wished to use the sockets via the fstream interface instead; this to my great discomfort failed. Can anyone describe the correct usage of fstream in socketing applications?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >CUJ (Dec 2001)


    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    3
    I am sorry I was not very specific in my earlier post; but the program is already constructed in a fashion similar to the construction you described.
    The socket is therefor already encapsulated in a class yet it is still using c-style functions to manage the transmissions. I have previously seen examples of socket classes inheriting from the fstream object defined in the c++ standard; but I had sadly forgotten the link and was unable to recall the neither the example nor the proper usage of the fstream class in socketing applications and would therefor be most thankfull for a correct description of its usage.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    By fstream interface I thought you meant the << and >> operators, all you have to do is overload them for your socket class. It's just that simple.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    3
    You are probably correct... I should probably stick to the current version and not tamper with it since it despite of its slight ugliness do work... Thanks anyway.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 09:13 AM
  2. Calling IRichEditOle interface methods
    By Niara in forum C Programming
    Replies: 2
    Last Post: 01-16-2009, 12:23 PM
  3. Fstream. I/O
    By kevinawad in forum C++ Programming
    Replies: 2
    Last Post: 07-07-2008, 09:19 AM
  4. ARGH! fstream errors
    By OttoDestruct in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 10:37 PM
  5. OOP in C
    By lyx in forum C Programming
    Replies: 4
    Last Post: 11-23-2003, 12:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21