FBB::ClientSocket(3bobcat)
π FBB::ClientSocket(3bobcat) π
okay bestie, sit down, hydrate, because we're talking about FBB::ClientSocket β the third bobcat manual page (yes, 3bobcat, that's the vibe) for the class that lets you slide into some server's DMs over the Internet. β¨
πΈ NAME πΈ
FBB::ClientSocket β a Client Socket that connects to a Server in the Internet. it's giving main character connecting to the group chat, fr fr. π¦
β¨ SYNOPSIS β¨
#include <bobcat/clientsocket>
Linking option: -lbobcat
like yes, include the header, link the lib, we move. π
π DESCRIPTION π
so basically: you can construct an FBB::ClientSocket and have it connect to some server process out there in the internet. the socket it hands you can be used to initialize a std::istream and/or a std::ostream. the std::istream is for reading info from the server process that your FBB::ClientSocket connects to, and the std::ostream is for sending info to that same server process. π«Ά
and since a socket is lowkey just a file descriptor, you can profitably use the FBB::IFdStream, FBB::IFdStreamBuf, FBB::OFdStream, and FBB::OFdStreamBuf classes here. obsessed. π
β οΈ but bestie, heads up: having a socket available does not mean the communication protocol is defined. nope! it's (still) the programmer's responsibility to comply with an existing protocol, or to implement a tailor-made protocol. and that second situation means the sequence of input- and output operations is defined by you, the programmer. no cap. π
oh and also β a Unix Domain client socket can be defined using FBB::LocalClientSocket. different class, different lore. π§
π NAMESPACE π
FBB
all constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. periodt. π
β INHERITS FROM β
FBB::SocketBase
it's giving family tree, and we're the well-behaved child. π
π CONSTRUCTOR π
ClientSocket(std::string const &host, uint16_t port)β this constructor initializes anFBB::ClientSocketobject, getting it all ready for a connection to the specified port at the given host. if the socket could not be constructed, anFBB::Exceptiongets thrown. π€ and here's the thing β constructing the socket does not mean a connection has actually been established. to actually connect to the server, you gotta use the memberconnect()(peep below). β¨
Copy and move constructors (and assignment operators) are not available. π like, they're just not. don't ask, it's not happening.
π MEMBER FUNCTIONS π
all members of FBB::SocketBase (and therefore of FBB::InetAddress) are available, because FBB::ClientSocket inherits from these classes. inherited the whole wardrobe, basically. π
int connect()β this member returns a socket that can be used to communicate with the server process. anFBB::Exceptionexception is thrown if the connection could not be established, or if theSocketBasebase class could not properly be constructed. so yeah, wrap it, bestie. π₯
π¦ EXAMPLE π¦
see also the serversocket(3bobcat) example. π
#include <iostream>
#include <string>
#include <bobcat/clientsocket>
#include <bobcat/ifdstream>
#include <bobcat/ofdstream>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
try
{
if (argc == 1)
{
cerr << "Provide servername and port number\n";
return 1;
}
size_t port = stoul(argv[2]);
ClientSocket client(argv[1], port);
int fd = client.connect();
string line;
cout << "Connecting to socket " << fd << endl <<
"address = " << client.dottedDecimalAddress() << ", " <<
endl <<
"communication through port " << client.port() << endl;
IFdStream in(fd); // stream to read from
OFdStream out(fd); // stream to write to
while (true)
{
// Ask for a textline, stop if
cout << "? "; // empty / none
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";
getline(in, line); // Wait for a reply from the server
cout << "Answer: " << line << endl;
}
}
catch (Exception const &err)
{
cerr << err.what() << "\n" <<
"Canβt connect to " << argv[1] << ", port " <<
argv[2] << endl;
return 1;
}
π FILES π
bobcat/clientsocket β defines the class interface. that's it, that's the file, she's the blueprint. πβ¨
π SEE ALSO π
bobcat(7), ifdstream(3bobcat), ifdbuf(3bobcat), inetaddress(3bobcat), localclientsocket(3bobcat), ofdstream(3bobcat), ofdstream(3bobcat), serversocket(3bobcat), socketbase(3bobcat)
(yes ofdstream(3bobcat) is listed twice β iconic of it, honestly, we respect the double feature π)
π BUGS π
None Reported.
literally flawless. not a single bug to drag. we love to see it. πβ¨
π BOBCAT PROJECT FILES π
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
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. yes bestie, it's a backronym and it ATE. π₯
πΈ COPYRIGHT πΈ
This is free software, distributed under the terms of the GNU General Public License (GPL).
free as in freedom, slay as in slay. π«Ά
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl).
the legend herself/himself, the icon, the moment. π
and that's the whole page diva!! π source and version: libbobcat-dev_6.15.01, dated 2005-2026, and yes this manual page is literally called FBB::ClientSocket(3bobcat) β go connect to something, bestie, but remember: implement your protocol first. no cap. π
β¨π¦
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms