FBB::Lo...tSocket(3bobcat)

πŸ’– FBB::LocalClientSocket β€” the Unix Domain client socket, bestie edition πŸ’–

okay so this is a page from bobcat, section 3bobcat β€” that's the manual name, consider it folded into your hair like a lil flower πŸŽ€ β€” all about FBB::LocalClientSocket. It's the client half of a Unix Domain socket convo. Let's get into it, no cap.


🌸 NAME 🌸

FBB::LocalClientSocket β€” a Client Socket that connects to a Server over in the Unix Domain. it's giving "i make the call, you pick up" πŸ“ž


✨ SYNOPSIS ✨

#include <bobcat/localclientsocket>
Linking option: -lbobcat

that's it, that's the whole vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So. You can construct an FBB::LocalClientSocket to connect to a server process in the Unix Domain. The socket that the FBB:LocalClientSocket hands you can be used to initialize a std::istream and/or a std::ostream. The std::istream is what you use to read info coming from the server process that your FBB::LocalClientSocket is connected to, and the std::ostream is what you use to send info to that server process. πŸ”„

And because a socket can be thought of as a file descriptor, the classes FBB::IFdStream, FBB::IFdStreamBuf, FBB::OFdStream, and FBB::OFdStreamBuf are all right there and may be used profitably here. girl, use them. 🫢

⚠️ but real talk β€” just having a socket does not mean the communication protocol is defined. That's still on the programmer: comply with an existing protocol, or implement a tailor-made one. And that latter situation implies the sequence of input- and output operations is defined by the programmer. yes. YOU. you're the protocol architect now, main character energy. πŸ‘‘

πŸ’œ NAMESPACE πŸ’œ

FBB

All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. periodt.


🧚 INHERITS FROM 🧚

FBB::LocalSocketBase

it literally inherited the whole aesthetic from its parent. slay.


πŸŽ€ CONSTRUCTOR πŸŽ€

  • LocalClientSocket() β€” this constructor merely creates a FBB::LocalClientSocket object. Before it can be used, its open() member must be called. so like, it exists, but it's not ready ready, yk? πŸ™ˆ
  • LocalClientSocket(std::string const &name) β€” this constructor initializes an FBB::LocalClientSocket object, using the named Unix Domain socket to connect to the server using the named Unix Domain socket. An FBB::Exception is thrown if the socket could not be constructed. And heads up bestie: the construction of the socket does not mean that a connection has actually been established. In order to connect to the server, the member connect() (see below) should be used. it's constructed, not connected β€” two different things, iykyk 😭

Copy and move constructors (and assignment operators) are not available. nope. not invited to the party. πŸ’€


🌈 MEMBER FUNCTION 🌈

  • int connect() β€” this member returns a socket that can be used to communicate with the server process. An FBB::Exception exception is thrown if the connection could not be established. this is the moment. the ✨connection✨. πŸ”₯
  • open(std::string const &name) β€” this member function prepares the FBB::LocalClientSocket object, constructed earlier using the default constructor, for use. The named Unix Domain socket is used to connect to the server using the named Unix Domain socket. An FBB::Exception is thrown if the socket could not be constructed. The construction of the socket does not mean that a connection has actually been established. In order to connect to the server, the member connect() should be used. same energy as the string constructor honestly, it's just the glow-up path for a default-constructed object. 🌸

⭐ EXAMPLE ⭐

See also the localserversocket(3bobcat) example.

#include <iostream>
#include <bobcat/localclientsocket>
#include <bobcat/ifdstream>
#include <bobcat/ofdstream>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
try
{
    if (argc == 1)
    {
        cerr << "Provide filename representing the unix domain socket\n";
        return 1;
    }

    LocalClientSocket client(argv[1]);
    int fd = client.connect();
    string line;

    cout << "Connecting to socket " << fd << endl;

    IFdStream in(fd);                 // stream to read from
    OFdStream out(fd);                // stream to write to

    while (true)
    {
                                // Ask for a textline, stop if empty / none
        cout << "? ";
        if (!getline(cin, line) || line.length() == 0)
            return 0;
        cout << "Line read: " << line << endl;
                                // Return the line to the server
        out << line.c_str() << endl;
        cout << "wrote line\n";

                                // Wait for a reply from the server
        getline(in, line);
        cout << "Answer: " << line << endl;
    }
}
catch (Exception const &err)
{
    cerr << err.what() << "\n" <<
            "Can’t connect to " << argv[1] << ", port " << argv[2] << endl;
    return 1;
}

look at that little loop go β€” ask, send, wait, answer, repeat. iconic behaviour fr fr. πŸ’…


πŸ“ FILES πŸ“

bobcat/localclientsocket β€” defines the class interface


πŸ‘‘ SEE ALSO πŸ‘‘

bobcat(7), ifdstream(3bobcat), ifdbuf(3bobcat), clientsocket(3bobcat), localserversocket(3bobcat), localsocketbase(3bobcat), ofdstream(3bobcat), ofdstream(3bobcat)

(yes, ofdstream(3bobcat) is listed twice in the original β€” we do not edit the sacred texts, we just love it twice πŸ’–)


πŸ™ˆ BUGS πŸ™ˆ

None Reported.

not a single one. we're clean. we're thriving. ✨


🌸 BOBCAT PROJECT FILES 🌸

Debian Bobcat project files:

  • libbobcat6 β€” debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev β€” debian package containing the static library, headers, manual pages, and developer info;

πŸŽ€ BOBCAT πŸŽ€

Bobcat is an acronym of Brokken’s Own Base Classes And Templates. cute AND functional, we love an acronym that serves. 🫢


This is free software, distributed under the terms of the GNU General Public License (GPL).

free as in freedom, bestie. πŸ¦‹


🌈 AUTHOR 🌈

Frank B. Brokken (f.b.brokken@rug.nl).


and that's the whole page!! tysm for reading, mwah πŸ’‹ β€” this was libbobcat-dev_6.15.01, dated 2005-2026, and yes the page title really is styled FBB::Lo...tSocket(3bobcat) because the header got a lil βœ‚οΈ trimmed. go forth and connect to your server, you've got this. πŸŽ€βœ¨

πŸ“¦ where this page comes from