471,330 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

dude about sockets

Hi,

Im starting working with sockets.

im making a server and a client (tipical starter) application.

About the BeginReceive Method, i dont understand why if i execute the line
one time, i only can send and receive a message, if i execute 10 times i can
send and receive 10... Do you know how BeginReceive method works?

--
Thanks a lot
Josema
Jan 12 '06 #1
3 1032
Josema wrote:
Im starting working with sockets.

im making a server and a client (tipical starter) application.

About the BeginReceive Method, i dont understand why if i execute the line
one time, i only can send and receive a message, if i execute 10 times i can
send and receive 10... Do you know how BeginReceive method works?


It's not entirely clear what you mean. Could you give a concrete
example, preferrably with some code which shows the problem? See
http://www.pobox.com/~skeet/csharp/complete.html for what I mean by
that.

Note that BeginRead gives you *asynchronous* IO - do you really need
that? You might want to try writing your code synchronously to start
with, then look at making it asynchronous.

Jon

Jan 12 '06 #2
Josema,

If you call the BeginReceive method, you are returned an implementation
of IAsyncResult, which represents that asynchronous call. The BeginSend
method will also allow you to pass a callback method which is executed when
the operation completes.

You should be able to do these as much as you want.
"Josema" <Je******@ocu.org> wrote in message
news:9E**********************************@microsof t.com...
Hi,

Im starting working with sockets.

im making a server and a client (tipical starter) application.

About the BeginReceive Method, i dont understand why if i execute the line
one time, i only can send and receive a message, if i execute 10 times i
can
send and receive 10... Do you know how BeginReceive method works?

--
Thanks a lot
Josema

Jan 12 '06 #3
Just a guess here, but I'm thinking your problem has something to do
with always being able to read and write and not wanting to always call
BeginReceive. If you use your socket to obtain a NetworkStream, then
the NetworkStream object has some attributes that you can use to know
when to call BeginReceive. Some of these attributes are .DataAvailable,
..CanWrite, and .CanReceive. I hope these help and sorry if this isn't
what you meant.

Jan 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tero Saarni | last post: by
1 post views Thread by Dmitry Akselrod | last post: by
reply views Thread by mrpolitics | last post: by
3 posts views Thread by Logan McKinley | last post: by
3 posts views Thread by Michael Maercker | last post: by
reply views Thread by rosydwin | 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.