新的C ++套接字库 [英] New C++ sockets library
问题描述
我创建了一个新的C ++套接字库 - 小型,跨平台,IPv4
和IPv6。如果有人想批评它,我会很感激。
不支持更奇特的协议 - 只有TCP和UDP。它还有
缺少get / setsockopt和ioctl,但这些可能会在将来添加。
目前还没有网页,我打算制作一次,我100%肯定
的一切。目前可在此处获取源:
http://dev.int64。 org / netx.zip
PS。查看socket :: select代码。这是我不喜欢的唯一部分,
但是我无法想出更好的解决方案。
I''ve created a new C++ sockets library - small, cross-platform, IPv4
and IPv6. If anyone would like to critique it, I''d appreciate it.
Doesn''t support the more exotic protocols - only TCP and UDP. It also
lacks get/setsockopt and ioctl, but those may be added in the future.
There is no webpage for it yet, I plan on making one once I''m 100% sure
of everything. For now the source is available here:
http://dev.int64.org/netx.zip
PS. Look at the socket::select code. It''s the only part I don''t like,
but I couldn''t come up with a better solution.
推荐答案
>小型,跨平台,IPv4和IPv6
像这样的包装良好的套接字类是迈向
$的第一步b $ b跨平台套接字库。代码如
sock.send(" hello",6);
意味着你还有办法去做简单的插座和
安全。
>small, cross-platform, IPv4 and IPv6
Thinly wrapped socket classes like these are the first steps toward a
cross platform sockets library. Code like
sock.send("hello", 6);
means you still have a way to go to make working with sockets easy and
safe.
如果有人想批评它,我会很感激。
我不喜欢的小东西是
1. c样式演员代替static_cast
2 。using namespace std而不是使用std :: string
3.将下划线放在成员变量前面
查看socket :: select code
If anyone would like to critique it, I''d appreciate it.
Small things I don''t like are
1. c style casts instead of static_cast
2. "using namespace std" instead of "using std::string"
3. putting underscore in front of member variables
Look at the socket::select code
我不会尝试为多个客户端使用select。对于服务器,请考虑一个接口,以便于使用异步I / O. (在Windows上
查看重叠的I / O,I / O完成端口和线程池)
每个人都想用C ++建立网络,所以继续。
I would not try and use select for multiple clients. For servers think
about an interface to make it easy to use asynchronous I/O. (On windows
look at overlapped I/O, I/O completion ports and thread pooling)
Everyone wants networking in C++, so keep going.
>像这样的精简包装的套接字类是迈向
> Thinly wrapped socket classes like these are the first steps toward a
跨平台套接字库的第一步。代码如
sock.send(" hello",6);
意味着您还有办法轻松使用套接字
和安全。
是的,我一直想为它制作一个基于蒸汽的界面 - 但我
我不知道怎么样:)我也是害怕我不会那么用它。
cross platform sockets library. Code like
sock.send("hello", 6);
means you still have a way to go to make working with sockets easy and safe.
Yea, I''ve been wanting to make a steam-based interface for it - but I
don''t know how :) I also fear I wouldn''t use it that much.
如果有人想批评它,我会很感激。
我不喜欢的小事
1. c style casts而不是static_cast
2.使用namespace std"而不是使用std :: string
3.将下划线放在成员变量前面
If anyone would like to critique it, I''d appreciate it.
Small things I don''t like are
1. c style casts instead of static_cast
2. "using namespace std" instead of "using std::string"
3. putting underscore in front of member variables
同意。我来自C背景,不习惯长期演员
运营商。使用可以很容易修复,但下划线有一个原因 - VS.NET中的Intellisense可能会混乱使用
私有方法/变量,所以我使用它将它们分开。
Agreed. I come from a C background, not used to the long cast
operators. The using can easily be fixed, but the underscores are
there for a reason - Intellisense in VS.NET can get cluttered with
private methods/variables, so I use it to seperate them.
查看socket :: select代码我不会尝试使用select for multiple clients。对于服务器
Look at the socket::select code I would not try and use select for multiple clients. For servers
考虑一个接口,使其易于使用异步I / O. (在
windows上查看重叠的I / O,I / O完成端口和线程池)
每个人都想用C ++建立网络,所以继续。
think about an interface to make it easy to use asynchronous I/O. (On
windows look at overlapped I/O, I/O completion ports and thread pooling)
Everyone wants networking in C++, so keep going.
是的,但在某些情况下它是好的。我已经为I / O完成端口开发了一个好的包装器。
Yup, but it is good in some instances. I''ve already been working on a
nice wrapper for I/O Completion ports.
"是的,我我一直想为它制作一个基于蒸汽的界面 - 但是我
我不知道怎么样:)我也担心我不会那么用它。
*流
"Yea, I''ve been wanting to make a steam-based interface for it - but I
don''t know how :) I also fear I wouldn''t use it that much."
*stream
这篇关于新的C ++套接字库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!