.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

TCP Client/Server communication: NetworkStream.Write() send partial data unless close() method is re

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :.NET Framework
Hi to all,
I wrote a simple client-server application that comunicate through NetworkStream class. The problems comes when stream.close() and client.close() methods are called. It look like only the first 10415 bytes are sent once those methods are called. So, if the data to send is more than this size, it is automatically truncated.

If I  remove both stream/client close() methods from the code, the data is fully received whatever the size is. I tried various alternative solutions (the ones marked as comments in the sample code), but none of them works.
The only thing that seems to work is adding a manual delay before the close() methods execute with something like that:

For Counter as integer = 0 to 10

The problem is that after delay I still don't know if all the data has been transfered or not. In addition to that, I will have to wait 10 seconds before sending another request, even if the response is just a few bytes of data. I could change at runtime the number of seconds to wait according to the size of the data to send, but I still think that delay is not a solution and will cause adverse effects.

So, for now the only working solution is to remove both Stream/Client Close() methods from

View Complete Post

More Related Resource Links

Sys.Data.DataContext.saveChanges method doesn't send update to server after DataServiceException ex

Hello,I have a page with a simple form that updates a single record in a table in my database.The database is accessed via WCF Data Services. To load and save data from/to the server, I usethe Sys.Data.DataContext object provided by the ASP.NET AJAX library. When the "save" button on theform is clicked, I use the saveChanges method of the Sys.Data.DataContext object to send all changes to the server.Also, at the server side, I use an interceptor that checks the "Price" fields of the record, and throws a DataServiceException exception when the contents of the field is a negative number.Both the JavaScript and the interceptor (in C#) are copied below.Here is the interesting thing:When I enter a negative price in the form, the interceptor throws the exception and my form shows an error message. Good.However, if I then make one of the other fields in the form a bit shorter (for example from "abcd" to "abc"),the saveChanges method doesn't send the data to the server. But it does call the success callback that I passed in to saveChanges, creating the impressionthat the data has been saved. This happens while the Price field is still negative. I used Fiddler to make sure thatno message is sent to the server. Also, the interceptor doesn't get executed.The weird thing is that if I make one of the fields a bit longer instead (for example &q

Best way to send data to report server from merge replicated database

Hi ALL,              I have merge replication configured on database say Testdb on production server. I want data from testdb(merge replicated) database to send to report server. How can i accomplish this....Whts the best way to send data at regular intervals to report server.. Any suggestions plz TIA

Push data from Server to Client?

Hello,Is it possible to push server from server to client?  For example (assuming inProc state management), there are three currently active sessions.  An event occurs in the server which causes it to 'push' data updates to all of these active clients?I've been banging my head against this one for a few days now - please help!Thanks,Mark.

Programatically Send and receive data using Post Method

Hi,I wish to make a script which programatically send the POST data to one server and then the other server receive the POST message and retrieve the information. How should make this work? I already successfully write the sender site, the code as follow:string postData = "id=0&co=5";ASCIIEncoding encode = new ASCIIEncoding();         //data encoding         byte[] dataEncode = encode.GetBytes(postData);         //end ascii encoding scheme         string url = "http://localhost:51711/Handler1.ashx"; //         //web request         HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);         req.Method = "POST";         req.ContentType = "application/x-www-form-urlencoded";         req.ContentLength = dataEncode.Length;         //send data                Stream st = req.GetRequestStream();         st.Write(dataEncode, 0, dataEncode.Length);         st.Close();ASCIIEncoding encode = new ASCIIEncoding();byte[] dataEncode = encode.GetBytes(postData);stri

Why Windows Close Button send data to SQL?


Hi all.


I have UI app windows with combo boxes which updating data into SQL Store Procedure.

I open UI windows do some updating data update correctly but is A problem rise when I open window again and  do nothing only close windows by clicking button close("X") on win a application updating sql table as if I click button send...

Moving from Client Server to Dynamic Data


I am a Visual Basic 6 Client- Server's applications developer. I have followed the first steps to create a scaffolded site. It was easy and it works fine, roughly. Dynamic data seems very powerful but it just makes me believe that it could be an excellent tool for supporting development only. Any real experience deployed with it? I understand that ASP.Net is of the disconnected type but I feel a little lost when variables are not there? How do you manage state? D.D.

How to send data from server on server


 private static void Upload(string ftpServer, string userName, string password, string filename)
        using (System.Net.WebClient client = new System.Net.WebClient())
            client.Credentials = new System.Net.NetworkCredential(userName, password);
            client.UploadFile(ftpServer + "/" + new FileInfo(filename).Name, "STOR", filename);

    protected void Page_Load(object sender, EventArgs e)
        Upload("ftp://ftp.test.net/", "username", "pass", "C:\tekme.JPG");

This code works, but I would like from server to server send the file.

This is not work: Upload("ftp://ftp.test.net/", "username", "password", "www.test.com/file.jpg");


Data extraction through ssis in client server concept


i am working on a data warehousing project for health care.i want to work on an architecture like this and need help...

1. source system is on another machine in sql server 2000.

2. data staging area database in sql server 2008 is used for temporary data stay on another machine.

3. target data warehouse in sql server 2008 is on third machine.

How to import data through ssis from a data table in sql server from machine and put it into sql server or any other RDBMS on another machine.

Sending Binary Data from Server to Client



I want to send a file by converting it into binary file to the client end and then it should be read by javascript which again I am passing to the OCX method.(like my OCX method accept only the binary data so i have to transmit binary data from server side to client).

Kindly provide me some solution.

Passing Huge data from client to server + WCF


Hello all,

I am trying to pass a large chunk of data from client to server.

I am getting a bad request message when i pass the data to my service.

can nyone plshelp.

i am adding my config file data over here.










Server call client machine and pick data from client service.


HI All,

Does anyone have any opinions over the best ways to connect a server to client service over internet to get data on server website.

If you have any idea and solution then please feedback me . Thanks 




MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Accessing SharePoint 2010 Data with Server-Side APIs

Accessing SharePoint data in server-side solutions is one of the most common tasks that you will perform as a SharePoint developer. SharePoint 2010 provides powerful server-side APIs that enable you to retrieve, add, edit, and delete SharePoint data programmatically. SharePoint 2010 also includes the new LINQ to SharePoint technology that enables you to work with SharePoint data efficiently and easily.

Sorting Data in a GridView Web Server Control

The GridView control provides built-in sorting functionality without requiring any coding. You can further customize the sort functionality of the GridView control by using custom SortExpression property values for columns as well as by using the Sorting and Sorted events

Frequently Asked Questions - SQL Server Data Types

This is good and precise introduction and Frequently Asked Questions - SQL Server Data Types

Serial Port Communication Read and Write using C#.net

In this simple article you will learn that how you can Open and read COM port data using System.IO.Ports Namespace.
Simply just create New Project of windows application in C#.

Import ServiceProcess APIs
using System.IO.Ports

Imports System.IO.Ports

Write Parsing functions which parse port data according to attached device

Send Email from SQL Server Express Using a CLR Stored Procedure

One of the nice things about SQL Server is the ability to send email using T-SQL. The downside is that this functionality does not exist in SQL Server Express. In this tip I will show you how to build a basic CLR stored procedure to send email messages from SQL Server Express, although this same technique could be used for any version of SQL Server.

If you have not yet built a CLR stored procedure, please refer to this tip for what needs to be done for the initial setup.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend