Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

Block a receive call

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Javier - 05 Aug 2005 13:00 GMT
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.
jianglinchun - 06 Aug 2005 16:53 GMT
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/details.aspx?familyid=08e3d5f8-033d-420b-a3b1
-3074505c03f3&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. :D

Regards
jianglinchun@diyinside.com

> Hello:
> I have an strange problem. i am new in sockets, and i'm developing a
[quoted text clipped - 30 lines]
> Thanks for the help.
> Bye.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.