473,388 Members | 1,385 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Socket+StreamWriter

I have a server that listen a socket.

And I have next client:

TcpClient socketForServer = new TcpClient("IVBEZUGLIY", 21000);
NetworkStream networkStream = socketForServer.GetStream();
StreamWriter streamWriter = new StreamWriter(networkStream);
streamWriter.Write("Hello12345!!!");
streamWriter.Flush();
//streamWriter.Close();

socketForServer = new TcpClient("IVBEZUGLIY", 21000);
networkStream = socketForServer.GetStream();
streamWriter = new StreamWriter(networkStream);
streamWriter.Write("Bye-bye!!!");
streamWriter.Flush();
//streamWriter.Close();
But server get only first message.
If I remove comments, then server get both messages.
Is it a bug? Or I do not know something?
Jul 21 '05 #1
1 3494
Vladimir Bezugliy <vb**@inbox.ru> wrote:
I have a server that listen a socket.

And I have next client:

TcpClient socketForServer = new TcpClient("IVBEZUGLIY", 21000);
NetworkStream networkStream = socketForServer.GetStream();
StreamWriter streamWriter = new StreamWriter(networkStream);
streamWriter.Write("Hello12345!!!");
streamWriter.Flush();
//streamWriter.Close();

socketForServer = new TcpClient("IVBEZUGLIY", 21000);
networkStream = socketForServer.GetStream();
streamWriter = new StreamWriter(networkStream);
streamWriter.Write("Bye-bye!!!");
streamWriter.Flush();
//streamWriter.Close();
But server get only first message.
If I remove comments, then server get both messages.
Is it a bug? Or I do not know something?


When you close the StreamWriter, that's also closing the connection.
Does your server listen for multiple connections, or does it only pick
up the first connection to come in?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daniel | last post by:
after opening socket, sending data then closing socket 3000 times i get "Only one usage of each socket address" what am i doing wrong? is there some thing else i need to do to free up the socket...
3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
4
by: Brian Rice | last post by:
I have a socket application that is sending and receiving packets asynchronously. It works great except, when I receive packets that are larger than my receive buffer which then generate several...
7
by: | last post by:
Hi all, I have a simple .aspx page running on net 2.0 that is trying to do a http post to a remote server. Here is the code Private Function ProcessRequests(ByVal strbody As String) As String...
1
by: Vladimir Bezugliy | last post by:
I have a server that listen a socket. And I have next client: TcpClient socketForServer = new TcpClient("IVBEZUGLIY", 21000); NetworkStream networkStream = socketForServer.GetStream();...
6
by: kikapu | last post by:
Hi to all, i have the following simple Socket Server code and a vb client that send to it some data using WinHttp. (very simple code, just open and send) The string is succesfully sent to the...
8
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi all, I am new to .net technologies. ASP.NET supports socket programming like send/receive in c or c++? I am developing web-site application in asp.net and code behind is Visual C#. In...
4
by: Andrew Jackson | last post by:
I am writing a newsgroup client. I have the protocol figured out. But I get slow transfer speeds off any of the network objects read the data from For example one of the commands for a news...
0
by: jrayasam | last post by:
Hi, I have a simple client server application which communicates through sockets. There is a content switch in between client and server that routes the request to a proper server machine. This...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.