持之以恒
分类: 网络与安全
2010-01-02 13:26:32
ACE_SOCK_Addr srvr(50000,ACE_LOCALHOST);//定义待连接的对端的地址
ACE_SOCK_Connector connector; ACE_SOCK_Stream peer; If(-1 == connector.connect(peer,srvr))
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT(“%p\n”),ACE_TEXT(“Connect”)),1);
}
|
peer.send_n(“update\n”,7);
bc = peer.recv(buf,sizeof(buf)); write(1,buf,bc); peer.close(); |
ACE_INET_Addr port_to_listen(50000);
ACE_SOCK_Acceptor acceptor; If(acceptor.open(port_to_listen,1)==-1) ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT(“%p\n”),ACE_TEXT(“acceptor.opn”)),100); |
If(acceptor.accept(peer,&peer_addr,&time_out,0)==-1)
{ //提示相应的信息 } |