wxSocket怎么传送文件呢? Topic is solved

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
hats
Experienced Solver
Experienced Solver
Posts: 70
Joined: Wed Sep 16, 2009 3:50 pm
Location: China
Contact:

wxSocket怎么传送文件呢?

Post by hats » Thu Jun 10, 2010 4:41 am

如题,能做通讯了,但还不知道怎样传送文件,谁能给个小例子?

liuyug
Experienced Solver
Experienced Solver
Posts: 53
Joined: Wed Jul 09, 2008 4:32 am

Post by liuyug » Fri Jun 25, 2010 1:43 am

象socket一样,那么传送

hats
Experienced Solver
Experienced Solver
Posts: 70
Joined: Wed Sep 16, 2009 3:50 pm
Location: China
Contact:

Post by hats » Mon Jul 19, 2010 9:34 am

还是不太明白,下面是客户端发送和服务器接受的部分代码:

void wxClientDialog::OnButton1Click(wxCommandEvent& event) //客户端发送
{
wxString str = TextCtrl1->GetValue();
char msg[2000];
strcpy(msg,str.mb_str());
socket->Write(msg,sizeof(msg));//发送信息
}

-------------------
case wxSOCKET_INPUT://服务器处理接收信息

char buf[2000];
sock->Read(buf,sizeof(buf));
//ListBox1->Append(buf);//ListBox1显示聊天信息
break;

----------------------------
要发送一个111.zip怎么发呢?用wxSocketOutputStream吗?能给个例子吗?

hats
Experienced Solver
Experienced Solver
Posts: 70
Joined: Wed Sep 16, 2009 3:50 pm
Location: China
Contact:

Post by hats » Tue Jul 20, 2010 4:06 pm

没人。。

范家兵
In need of some credit
In need of some credit
Posts: 2
Joined: Sat Jul 21, 2012 7:29 am

Re: wxSocket怎么传送文件呢?

Post by 范家兵 » Sat Jul 21, 2012 8:10 am

我是先把文件读到缓冲区再把缓冲区里的数据通过socket传送的,但是我遇到一个问题,数据传送都没问题,TXT文件也没问题,但是其他的文件传送过后打不开。文件被破坏。 :cry:

Post Reply