471,306 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

TcpListener & Client - sends to many bytes

Hi
I have a problem:
when i send data:
byte[] fName =
ASCIIEncoding.ASCII.GetBytes(stringFileName);
TcpClient Client = new TcpClient();
Client.Client.Send(fName,fName.Length,SocketFlags. None);
in my case fName is 7

When i receive data on Server
byte[] buffer = new byte[256];
int size = connection.Receive(buffer);

Since size is number of received bytes, in my case it's 256
Any ideas?
PK

fName is filename. I need to send it, to allow server store file, but
until my received name is sentname+TRASH i can't create new file.

Nov 29 '05 #1
1 1333
Hi,

TcpClient.Client is a protected property , you cannot use it.
You use TcpClient.GetStream to get the networkstream .
You should send the size of the string before the string itself, in this way
you can know apriori the amount of data you will gonna get.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Piotrekk" <Pi*************@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi
I have a problem:
when i send data:
byte[] fName =
ASCIIEncoding.ASCII.GetBytes(stringFileName);
TcpClient Client = new TcpClient();
Client.Client.Send(fName,fName.Length,SocketFlags. None);
in my case fName is 7

When i receive data on Server
byte[] buffer = new byte[256];
int size = connection.Receive(buffer);

Since size is number of received bytes, in my case it's 256
Any ideas?
PK

fName is filename. I need to send it, to allow server store file, but
until my received name is sentname+TRASH i can't create new file.

Nov 29 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Michael Rybak | last post: by
10 posts views Thread by Shaniqua Jones | last post: by
2 posts views Thread by MuZZy | last post: by
2 posts views Thread by Chris Johnson | last post: by
5 posts views Thread by Yossarian | last post: by
3 posts views Thread by Jon Slaughter | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.