#include"stdafx.h"
#include"iostream"
#include "algorithm"
#include"string"
#include"vector"
#include"set"
#include"map"
#include "iostream"
#include "thread"
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include "rapidxml.hpp"
#include "rapidxml_utils.hpp"
#include <winsock2.h>
#include <windows.h>
#define MAX_PATH 256
#pragma comment( lib, "ws2_32.lib") int
evutil_socketpair(int family, int type, int protocol, int fd[])
{
/* This code is originally from Tor. Used with permission. */ /* This socketpair does not work when localhost is down. So
* it's really not the same thing at all. But it's close enough
* for now, and really, when localhost is down sometimes, we
* have other problems too.
*/
int listener = -;
int connector = -;
int acceptor = -;
struct sockaddr_in listen_addr;
struct sockaddr_in connect_addr;
int size;
int saved_errno = -; listener = socket(AF_INET, type, );
if (listener < )
{
return -;
}
memset(&listen_addr, , sizeof(listen_addr));
listen_addr.sin_family = AF_INET;
listen_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
listen_addr.sin_port = ; /* kernel chooses port. */
int err;
if (SOCKET_ERROR == bind(listener, (struct sockaddr *) &listen_addr, sizeof(listen_addr)))
return -;
if (listen(listener, ) == -)
goto tidy_up_and_fail; connector = socket(AF_INET, type, );
if (connector < )
goto tidy_up_and_fail;
/* We want to find out the port number to connect to. */
size = sizeof(connect_addr);
if (getsockname(listener, (struct sockaddr *) &connect_addr, &size) == -)
goto tidy_up_and_fail;
if (size != sizeof(connect_addr))
goto abort_tidy_up_and_fail;
if (connect(connector, (struct sockaddr *) &connect_addr,
sizeof(connect_addr)) == -)
goto tidy_up_and_fail; size = sizeof(listen_addr);
acceptor = accept(listener, (struct sockaddr *) &listen_addr, &size);
if (acceptor < )
goto tidy_up_and_fail;
if (size != sizeof(listen_addr))
goto abort_tidy_up_and_fail;
/* Now check we are talking to ourself by matching port and host on the
two sockets. */
if (getsockname(connector, (struct sockaddr *) &connect_addr, &size) == -)
goto tidy_up_and_fail;
if (size != sizeof(connect_addr)
|| listen_addr.sin_family != connect_addr.sin_family
|| listen_addr.sin_addr.s_addr != connect_addr.sin_addr.s_addr
|| listen_addr.sin_port != connect_addr.sin_port)
goto abort_tidy_up_and_fail;
fd[] = connector;
fd[] = acceptor; return ; abort_tidy_up_and_fail:
saved_errno = WSAECONNABORTED;
tidy_up_and_fail:
return -;
} void main(){
WORD wVersionRequested;
WSADATA wsaData;
int err, iLen;
wVersionRequested = MAKEWORD(, );//create 16bit data
err = WSAStartup(wVersionRequested, &wsaData); //load win socket
int ev_signal_pair[];
evutil_socketpair(
AF_UNIX, SOCK_STREAM, , ev_signal_pair);
send(ev_signal_pair[], "nihao", , );
char c[] = { };
recv(ev_signal_pair[], c, , );
std::cout << c;
system("pause");
}

最新文章

  1. JS中的decodeURIComponent和encodeURIComponent
  2. MySQL For Windows修改最大连接数
  3. JavaScript 写几个简单的知识点
  4. PAT乙级 1019. 数字黑洞 (20)
  5. HZAU 17:LCS
  6. python中的 zip函数详解
  7. 【BZOJ】【2879】【NOI2012】美食节
  8. linux ubuntu卸载软件
  9. C字符串总结+字符串库实现(增,改,删,查):
  10. win10 uwp 通知列表
  11. 一:Tomcat 服务器 在45秒内未启动成功
  12. about:firefox set
  13. SQL Update
  14. php用PDO查询mysql数据库结果中文乱码
  15. easyUI dialog打开对话框,显示列表数据,选取一条数据操作后赋值给父窗口 resultMap声明为全局,生成getset方法
  16. XRecyclerView上拉刷新下拉加载
  17. zookeeper-架构设计与角色分工-《每日五分钟搞定大数据》
  18. js判断是手机端还是pc端访问
  19. (转)Springboot定时任务
  20. ubuntu 把软件源修改为国内源和更新

热门文章

  1. 前端 day 039
  2. 3.Exadata 软件体系结构
  3. enum学习
  4. kafaka安装
  5. Oracle命令整理
  6. log4j整理
  7. java泛型中的各种限制
  8. DEM、DSM、DOM 名词解释
  9. java使用netty的模型总结
  10. TD不换行 nowrap属性