Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Size type string

$
0
0

int nr = listenSocket2.Receive(buf,sizeof(ulong),SocketFlags.None);

I see type string only limit 8 bytes(8 character) although i set size buf is sizeof(ulong). Everybody can tell me how way to receive more than 8 bytes? Detail:

server

byte[]  buf =Encoding.ASCII.GetBytes(fileSize.ToString());MemoryStream ms =newMemoryStream();
        ms.Write(buf,0,buf.Length);
        ms.Seek(0,SeekOrigin.Begin);byte[] buf2 =newbyte[32*1024];
        ms.Read(buf2,0,buf2.Length);FileStream fs =File.OpenRead(savefilename);MessageBox.Show("1 "+ buf2.Length+" "+ fileSize+" "+ms.Length);int ns = sendSocket.Send(buf2,sizeof(ulong),SocketFlags.None);

client

byte[] buf =newbyte[32*1024];int nr = listenSocket2.Receive(buf,sizeof(ulong),SocketFlags.None);MemoryStream ms =newMemoryStream();
            ms.Write(buf,0, buf.Length);
            ms.Seek(0,SeekOrigin.Begin);byte[] buf2 =newbyte[32*1024];
            ms.Read(buf2,0, buf2.Length);string s1 =Encoding.ASCII.GetString(buf2);MessageBox.Show(""+ s1+" "+ms.Length);ulong fileSize =UInt64.Parse(s1);

s1 is not more than 8 character

https://www.mediafire.com/?qqbphpr3r2zbl92 \\link my app.


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>