Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

一个奇怪的问题

7 views
Skip to first unread message

无怨无悔

unread,
Oct 25, 1999, 3:00:00 AM10/25/99
to

我编了一个client/server程序,可是在client
connect(....)时有错误,经GetLastError(...)
查看错误为0,0又是什么错误呢?盼哪位大侠帮助!

程序的部分代码如下:
m_psock是一个类的对象,此类由CAsyncSocket派生而来:

m_psock=new CClientsock(this);
if(!m_psock->Create()){
AfxMessageBox("Client connect server error!");
int err=m_psock->GetLastError();
char buf[10];
gcvt(err,10,buf);
AfxMessageBox(buf);
}
BOOL ret=m_psock->Connect("202.119.25.233",5050);
if(!ret){
AfxMessageBox("Client connect server error!");
int err=GetLastError();
char buf[10];
AfxMessageBox(buf);
}
BOOL ret=m_psock->Connect("202.119.25.233",5050);
if(!ret){
AfxMessageBox("Client connect server error!");
int err=GetLastError();
char buf[10];
gcvt(err,10,buf);
AfxMessageBox(buf);
}
m_psock->Send("Hello,World!",12);
m_psock->Close();
delete m_psock;
m_psock=NULL;


奇怪的是虽然Connect(....)有错误,但是它发送给Server的消息
server可以收到!有谁知道这是什么原因吗?

谢谢了!

--
※ 来源: 中国科大BBS站 [bbs.ustc.edu.cn]

罗马假日

unread,
Oct 26, 1999, 3:00:00 AM10/26/99
to
> [1;36m==> Nicky_Sun(无怨无悔) 说道: [37;40m [0m

> 我编了一个client/server程序,可是在client
> connect(....)时有错误,经GetLastError(...)
> 查看错误为0,0又是什么错误呢?盼哪位大侠帮助!
> 程序的部分代码如下:
> m_psock是一个类的对象,此类由CAsyncSocket派生而来:
> BOOL ret=m_psock->Connect("202.119.25.233",5050);
> if(!ret){
^^^^^
若无错误发生,则connect()返回0。

> AfxMessageBox("Client connect server error!");
> int err=GetLastError();
> char buf[10];
> AfxMessageBox(buf);
> }

0 new messages