PC Review


Reply
Thread Tools Rate Thread

Block a receive call

 
 
=?Utf-8?B?SmF2aWVy?=
Guest
Posts: n/a
 
      5th Aug 2005
Hello:
I have an strange problem. i am new in sockets, and i'm developing a
client-server application. My client sends information to the server, and it
works. The server receives the information and sends an ACK to the client,
and it works too.
But the problem is that if the client "arrives" to the receive call before
the server sends the ACK, the client doesn't block, go on and receive
nothing...
The more strange thing is that it works in the server. It waits for the
information from the client, and if the information from the client arrives
later than the server arrives to the Receive call, the server waits.
i have the same call in both, this is the code:
---SERVER---
byte [] buf = new byte[1024];
while(true) {
try {
bytesLeidos = nuevoSocket.Receive(buf);
}
}

---CLIENT---
int longitud = socket.Available;
bufferLectura = new byte[longitud];
int resultado = socket.Receive(bufferLectura);


When i create the socket, in the server and in the client i define the
property Blocking of the Socket to TRUE.

Please help me, i am near to finish this application and can't do it until
it stupid thing works.
Thanks for the help.
Bye.



 
Reply With Quote
 
 
 
 
jianglinchun
Guest
Posts: n/a
 
      6th Aug 2005
nuevoSocket.Receive(buf);

-->The remark from .net framework sdk 1.1 class library:

If no data is available for reading, the Receive method will block until
data is available. If you are in non-blocking mode, and there is no data
available in the in the protocol stack buffer, the Receive method will
complete immediately and throw a SocketException. You can use the Available
property to determine if data is available for reading. When Available is
non-zero, retry the receive operation.

So I suggest you read the System.Net.Sockets.Receive() method's remark very
carefully.And the following url was point to a sample from microsoft(Both c#
and vb.net sample code are availd for you!)

http://www.microsoft.com/downloads/d...displaylang=en

You will find a folder named "Advanced .NET Framework (Networking) - Use
Sockets" after you intalled the 101 samples.And I am sure you will find out
how to solve your problem.Good luck.

-->I can not find a better example of socket programing so far.

Regards
(E-Mail Removed)


"Javier" <(E-Mail Removed)> wrote in message
news:C79A7919-7176-40A4-BA69-(E-Mail Removed)...
> Hello:
> I have an strange problem. i am new in sockets, and i'm developing a
> client-server application. My client sends information to the server, and
> it
> works. The server receives the information and sends an ACK to the client,
> and it works too.
> But the problem is that if the client "arrives" to the receive call before
> the server sends the ACK, the client doesn't block, go on and receive
> nothing...
> The more strange thing is that it works in the server. It waits for the
> information from the client, and if the information from the client
> arrives
> later than the server arrives to the Receive call, the server waits.
> i have the same call in both, this is the code:
> ---SERVER---
> byte [] buf = new byte[1024];
> while(true) {
> try {
> bytesLeidos = nuevoSocket.Receive(buf);
> }
> }
>
> ---CLIENT---
> int longitud = socket.Available;
> bufferLectura = new byte[longitud];
> int resultado = socket.Receive(bufferLectura);
>
>
> When i create the socket, in the server and in the client i define the
> property Blocking of the Socket to TRUE.
>
> Please help me, i am near to finish this application and can't do it until
> it stupid thing works.
> Thanks for the help.
> Bye.
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why call Connection.Close() in using block? csharper Microsoft C# .NET 2 24th Aug 2011 07:32 PM
Call Close in Using Block with StreamWriter JohnMSyrasoft Microsoft VB .NET 6 8th Apr 2008 02:59 AM
Call two script block's ruca Microsoft VB .NET 6 29th Apr 2005 03:09 PM
Call two script block's ruca Microsoft ASP .NET 6 29th Apr 2005 03:09 PM
Want my modem to disconnect on incoming call and receive the call. =?Utf-8?B?bWFp?= Windows XP Networking 0 20th Mar 2005 12:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:15 AM.