424,066 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,066 IT Pros & Developers. It's quick & easy.

c++ socket library

P: n/a


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.

Dec 12 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
ACE

"mthread" <rj****@gmail.comwrote in message
news:86**********************************@t1g2000p ra.googlegroups.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.
Dec 12 '07 #2

P: n/a
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
Dec 12 '07 #3

P: n/a
On Wed, 12 Dec 2007 12:26:22 +0200, mthread <rj****@gmail.comwrote:
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).

Boris
Dec 12 '07 #4

P: n/a
On Dec 12, 12:26 pm, mthread <rjk...@gmail.comwrote:
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...
Dec 12 '07 #5

P: n/a
mthread wrote:
>

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
Dec 12 '07 #6

P: n/a
"Default User" <de***********@yahoo.comwrote in news:5saulbF180f6cU1
@mid.individual.net:
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?

--
Tomás Ó hÉilidhe
Dec 12 '07 #7

P: n/a
Tomas S hIilidhe wrote:
"Default User" <de***********@yahoo.comwrote in news:5saulbF180f6cU1
@mid.individual.net:
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?
*plonk*

Brian
Dec 12 '07 #8

P: n/a
On Dec 13, 3:31 am, "Default User" <defaultuse...@yahoo.comwrote:
Tomas S hIilidhe wrote:
"Default User" <defaultuse...@yahoo.comwrote in news:5saulbF180f6cU1
@mid.individual.net:
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?

*plonk*

Brian
Hi,

thanx everyone for the help
Dec 13 '07 #9

P: n/a
mthread wrote:
On Dec 13, 3:31 am, "Default User" <defaultuse...@yahoo.comwrote:
Tomas S hIilidhe wrote:
"Default User" <defaultuse...@yahoo.comwrote in
news:5saulbF180f6cU1 @mid.individual.net:
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?
plonk
thanx everyone for the help
Sure, let me know if there's anyone else I can plonk for you.

Brian
Dec 13 '07 #10

P: n/a
mthread ha scritto:
>
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.
I'm using: http://www.alhem.net/Sockets/
It has some glitches, but I choosed it for its light weight.

bye
av.
Dec 13 '07 #11

P: n/a
On Dec 12, 2:26 am, mthread <rjk...@gmail.comwrote:
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.
Dec 14 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.