Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 835|回复: 0
打印 上一主题 下一主题

跪求熟悉vb.net tcp connection的大大赐教~!

[复制链接]

22

主题

1

好友

399

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

跳转到指定楼层
1#
发表于 2012-10-31 07:03 PM |只看该作者 |倒序浏览
小弟我遇到一个问题,就是client send image to server 的问题,我是用tcp connection,因为还有send一些文字...
上网找了,有人说用UDP比较快,可是TCP 比较稳定不是?
这是我的coding
client sending的:
        Dim mStream As New System.IO.MemoryStream()
        Dim bits() As Byte
        img.Save(mStream, Imaging.ImageFormat.Jpeg)
        bits = mStream.GetBuffer

        netStream = clientSocket.GetStream
        netStream.Write(bits, 0, bits.Length)
        netStream.Flush()

这是server receive的:
         netStream = incomingClient.GetStream
         Dim bytesRead(CInt(incomingClient.ReceiveBufferSize)) As Byte
         netStream.Read(bytesRead, 0, CInt(incomingClient.ReceiveBufferSize))

         Dim img As Image
         Dim mStream As IO.MemoryStream = New IO.MemoryStream(bytesRead)
         img = Image.FromStream(mStream)

         PictureBox1.Image = img
         
我发现到从client send出去的byte length是130065,可是server receive到的byte length只有8192,为什么啊?
然后造成img = Image.FromStream(mStream) 出现error: parameter not valid

如果没错,应该是receive少了,结果不能解读...
请高手赐教~




收藏收藏0
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-12-26 02:43 PM , Processed in 0.100847 second(s), 26 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部