473,399 Members | 3,106 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,399 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 3497
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.