Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
"mthread" <rjkumr@gmail.c omwrote in message
news:865f4253-8db3-4816-8f38-b9eeaca752ea@t1 g2000pra.google groups.com...
>
>
Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
>
>
Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
>
There is no standard socket library in C++. You can google for
standalone library or you can use a framework like: ACE, Poco, gtk+ ...
On Wed, 12 Dec 2007 12:26:22 +0200, mthread <rjkumr@gmail.c omwrote:
Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
Boost.Asio (see http://asio.sourceforge.net/; not yet part of the Boost
distribution although it has been accepted to Boost already).
On Dec 12, 12:26 pm, mthread <rjk...@gmail.c omwrote:
Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
Besides Ace, QT also offers networking classes which are very easy to
use, you'd have to check out their licensing model though...
>
>
Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
People have pointed out that there are no socket facilities in C++.
There also are none in C either. It's all platforms-specific stuff.
>
Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
>
On Dec 12, 2:26 am, mthread <rjk...@gmail.c omwrote:
Hi,
I am planning to write a TCP/IP server. I would like to know if
any socket library is available for c++ or I have to use the socket
function calls in C.
First understand the socket library -- how to use it in C to write
your TCP/IP server.
Then recognize that there are pairs of function calls like e.g. socket/
close. accept/close.
Such pairs create classes with the do-action in the constructor and
the undo action in the destructor. I call such classes resource-
wrappers.
The constructor should throw something derived from std::exception in
case of the call fails.
The object thrown should contain every error information provided by
the system:
e.g. errno and the name of the function call which failed and maybe
some user supplied string which explains what has been attempted to
do.
From the saved errno you get the system error string via strerror.
IN the constructor create a std::string which contains the final error
message the user will see.
The what() method of the exception class will return what is returned
from the std::string.c_s tr().
Then recognize that there are functions which can also fail but do not
create a resource, like e.g. read/write. These belong into what I call
functional-wrappers.
A function returning void and calling the function to be wrapped.
If the function to be wrapped fails, again throw something containing
all the error information.
Finally you can write your TCP/IP server using these wrappers. You
will have to write a single try-catch block to deal with errors. The
code you're writing using these wrappers does not deal with errors
anymore.
Comment