Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > VB.NET 2005 SOCKET PROBLEM
 

VB.NET 2005 SOCKET PROBLEM

hi every one,
i'm developping a server application using vb.net and i'm facing a problem. in fact i have a hudge data to send to the client via the socket so i use a loop to divide the data and send eatch part the problem is that when i proceed with the sending the socket send me only few peaces of the data and loose a big part of it. i tryed to flush the buffer after each sending but i didnt find how to do it so i used a system.threding.thread.sleep between each socket.send. it wors when i don't have hudge data but it blocks my server when the number of paquets increases. is there a solution that would replace the .sleep one without blocking the application??
enirys9  Wednesday, November 25, 2009 8:30 AM
> send me only few peaces of the data

The Send method can return without sending all of the bytes you provided to it. You need to examine the return value and loop if it is less than the total number of bytes you wanted to send.

There is a similar issue with Receive. Receive reads the bytes from the TCP/IP stream as them come in, which might not correlate exactly to invocations of Send on the other side.

See http://nitoprograms.blogspot.com/2009/04/tcpip-net-sockets-faq.html, especially the part on "framing", for a good tutorial.
BinaryCoder  Thursday, November 26, 2009 12:15 AM
> send me only few peaces of the data

The Send method can return without sending all of the bytes you provided to it. You need to examine the return value and loop if it is less than the total number of bytes you wanted to send.

There is a similar issue with Receive. Receive reads the bytes from the TCP/IP stream as them come in, which might not correlate exactly to invocations of Send on the other side.

See http://nitoprograms.blogspot.com/2009/04/tcpip-net-sockets-faq.html, especially the part on "framing", for a good tutorial.
BinaryCoder  Thursday, November 26, 2009 12:15 AM

You can use google to search for other answers

Custom Search

More Threads

• Rounding Numbers in a String
• Program to Program Communication
• Question: create pdf with version/counter control
• Access to Network attached storage
• Windows Task Manager
• Module's question with Visual Basic
• Edit Data in a .NET VS2005 Visual Basic ListView Control
• Handle Multiple Checkboxes & Textboxes
• Can't understand delegate function
• event _TextChanged