K
kuba bogaczewicz
Hello all,
for my school project I have to write a small peer-2-peer application
using Sockets, and I've chosen C# for the task.
I've been doing some research on the topic, and I would really
appreciate if someone checked if I got all things right.
I am going to use asynchronous connections, and here comes some of my
doubts:
-> I want to send each message in a scheme: 4 bytes with the size, then
actual message. According to MSDN I got with VS2003
BeginSend()/EndSend() and BeginReceive/EndReceive will block (in it's
own thread) until the desired amount of data is sent or received. But
I've seen in 'C# Network Programming', that the proper method of
sending would be in a loop checking how much data had been sent, and
resending what is left. Can I trust MSDN on this one - it will be
rather painful to do loop-sending with asynchronous methods, while
having
receive 4 bytes;
receive actual message;
will be quite easy.
-> does BeginSend() puts byte[] with data in some other system queue?
This question is rather essencial to me, because on one Socket
connection I will be sending possibly a couple of files, and also the
same Socket will have to be able to send 'search messages'. Each file
will be sent one part after another, no flooding socket. But durign
that sending user might want to send a 'search' message, and I will
have to do BeginSend() for this one. Can this somehow mess with byte
order sent through the socket?
if on the other side on the connetion application is constantly doing
BeginRecive;
EndReceive;
can this be making problems with buffors on any side?
I'd greatly appreciate quick responses,
thank you in advance
Kuba Bogaczewicz
for my school project I have to write a small peer-2-peer application
using Sockets, and I've chosen C# for the task.
I've been doing some research on the topic, and I would really
appreciate if someone checked if I got all things right.
I am going to use asynchronous connections, and here comes some of my
doubts:
-> I want to send each message in a scheme: 4 bytes with the size, then
actual message. According to MSDN I got with VS2003
BeginSend()/EndSend() and BeginReceive/EndReceive will block (in it's
own thread) until the desired amount of data is sent or received. But
I've seen in 'C# Network Programming', that the proper method of
sending would be in a loop checking how much data had been sent, and
resending what is left. Can I trust MSDN on this one - it will be
rather painful to do loop-sending with asynchronous methods, while
having
receive 4 bytes;
receive actual message;
will be quite easy.
-> does BeginSend() puts byte[] with data in some other system queue?
This question is rather essencial to me, because on one Socket
connection I will be sending possibly a couple of files, and also the
same Socket will have to be able to send 'search messages'. Each file
will be sent one part after another, no flooding socket. But durign
that sending user might want to send a 'search' message, and I will
have to do BeginSend() for this one. Can this somehow mess with byte
order sent through the socket?
if on the other side on the connetion application is constantly doing
BeginRecive;
EndReceive;
can this be making problems with buffors on any side?
I'd greatly appreciate quick responses,
thank you in advance
Kuba Bogaczewicz