c++ socket library

M

mthread

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.
 
M

Michael DOUBEZ

mthread a écrit :
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+ ...

Michael
 
T

Tomás Ó hÉilidhe

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.



Could I take this opportunity to invite you to give your support for
the founding of "comp.lang.c++.cross-platform" (don't worry it doesn't
involve money!). You can vote for its founding by posting to the thread
entitled "RFD: comp.lang.c++.cross-platform" in the newsgroup
"news.groups.proposals". Every supporter counts, and we only need a couple
more to get the newsgroup up and running.

Comp.lang.c++.cross-platform would be a great place to discuss what
libraries to use for TCP/IP programming in C++, and for people to discuss
TCP/IP cross-platform programming in general.
 
M

Michael DOUBEZ

Tomás Ó hÉilidhe a écrit :
Could I take this opportunity to invite you to give your support for
the founding of "comp.lang.c++.cross-platform" (don't worry it doesn't
involve money!). You can vote for its founding by posting to the thread
entitled "RFD: comp.lang.c++.cross-platform" in the newsgroup
"news.groups.proposals". Every supporter counts, and we only need a couple
more to get the newsgroup up and running.

I haven't seen any reference to cross-plateform requierement from the
OP. Some librairies/frameworks are more or less cross-plateform in order
to extend their user community or to effectively allow porting but it is
not the issue here.
Comp.lang.c++.cross-platform would be a great place to discuss what
libraries to use for TCP/IP programming in C++, and for people to discuss
TCP/IP cross-platform programming in general.

To the contrary, the OP would be better with a library that fits his
needs without the oddments due to interface factorisation.

Michael
 
R

Ralf Globisch

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...
 
D

Default User

mthread said:
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.





Brian
 
T

Tomás Ó hÉilidhe

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.


Never heard of cross-platform libraries?
 
P

Peter

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_str().
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top